作为一个前端攻城狮,CSS那绝对是基础,可是基础也有掌握不牢的时候。今天就来总结一下容易写错的CSS属性简写问题。
1、background
背景颜色:background-color 基本语法:background-color : transparent | color
背景图像:background-image 基本语法:background-image : none | url ( url )
背景图像铺排:background-repeat 基本语法:background-repeat : repeat | no-repeat | repeat-x | repeat-y
背景图像滚动还是固定:background-attachment 基本语法:background-attachment : scroll | fixed
背景图像位置:background-position 基本语法:background-position : length || length或 background-position : position || position
length : 百分数 | 由浮点数字和单位标识符组成的长度值。请参阅 长度单位
position : top | center | bottom | left | center | right
以上是经常用到的background属性,大家一般都很熟悉,
其简写方式为:background : background-color || background-image || background-repeat || background-attachment || background-position
可是随着css的发展CSS3中又引入了其他4个属性:
背景的裁剪区域:background-clip 基本语法:background-clip : border-box | padding-box | content-box | no-clip
border-box:从border区域向外裁剪背景。
padding-box:从padding区域向外裁剪背景。
content-box:从content区域向外裁剪背景。
no-clip:从border区域向外裁剪背景。
背景显示区域:background-origin 基本语法:background-origin : border | padding | content
设置背景图片大小:background-size 基本语法:background-size :[
多重背景background : [background-image] | [background-origin] | [background-clip] | [background-repeat] | [background-size] | [background-position]
例如:background: url(img/multiple-backgrounds.png) left top no-repeat, url(img/multiple-backgrounds.png) -320px bottom no-repeat, url(img/multiple-backgrounds.png) -640px top repeat-y;
终于完了!这么多属性怎么简写呢?
查了好多资料终于找到了,好东西就该拿出来分享:
其简写方式为:background: background-color||background-image||background-repeat||background-attachment||background-position / background-size||background-origin||background-clip;
注意里面的反斜杠,它更font和border-radius里简写方式使用的反斜杠的用法相似。
例如:background: red url("images/1.jpg") no-repeat scroll center center / 50% content-box content-box;
2、font
字体样式:font-style 基本语法:font-style : normal | italic | oblique
设置文本是否为小型的大写字母:font-variant 基本语法:font-variant : normal | small-caps
设置字体的粗细: font-weight 基本语法:font-weight : normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
设置字体尺寸 :font-size 基本语法:font-size : xx-small | x-small | small | medium | large | x-large | xx-large | larger |smaller | length
设置文本的字体名称序列: font-family 基本语法:font-family : ncursive | fantasy | monospace | serif | sans-serif
其简写方式为:font-style || font-variant || font-weight || font-size /line-height || font-family
例如:font:italic small-caps bold 12px/1.5em arial,verdana;
3、margin & padding 以margin为例,padding相同
其简写方式为:margin:margin-top margin-right margin-bottom margin-left;
例如:margin:1px 1px 1px 1px;
4、border
边框宽度:border-weight 基本语法:border-width : medium | thin | thick | length
边框样式:border-style 基本语法:border-style : none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset
边框颜色: border-color 基本语法:border-width :color
其简写方式为:border : border-width || border-style || border-color
例如:border:1px solid #000;
5、outline
outline类似border,不同的是border会影响盒模型,而outline不会。
其简写方式为:outline : outline-width || outline-style || outline-color
例如:outline:1px solid red;
6、border-radius
右上角半径:border-top-right-radius ,
右下角半径:border-bottom-right-radius ,
左下角半径:border-bottom-left-radius ,
左上角半径:border-top-left-radius
当各个圆角半径相同时其简写方式为:border-radius :border-top-right-radius border-bottom-right-radius border-bottom-left-radius border-top-left-radius;
例如:border-radius:0 6px 6px 6px;一般简写为 border-radius:0 6px 6px;
当各个圆角半径不同时其简写方式为:border-radius : none |
例如:border-radius:0px 5px 10px 15px/20px 15px 10px 5px;按照上有下左的规律依次写出每个角的两条边的半径
7、color的简写就不说了,太简单了
不知道总结的好不好,若有错烦指出,谢谢!

HTML、CSS和JavaScript在网页开发中的作用分别是:1.HTML用于构建网页结构;2.CSS用于美化网页外观;3.JavaScript用于实现动态交互。通过标签、样式和脚本,这三者共同构筑了现代网页的核心功能。

设置标签的lang属性是优化网页可访问性和SEO的关键步骤。1)在标签中设置lang属性,如。2)在多语言内容中,为不同语言部分设置lang属性,如。3)使用符合ISO639-1标准的语言代码,如"en"、"fr"、"zh"等。正确设置lang属性可以提高网页的可访问性和搜索引擎排名。

htmlattributeseresene forenhancingwebelements'functionalityandAppearance.TheyAdDinformationTodeFineBehavior,外观和互动,使网站互动,响应式,visalalyAppealing.AttributesLikutesLikeSlikEslikesrc,href,href,href,类,类型,类型,和dissabledtransfransformformformformformformformformformformformformformformforment

toCreateAlistinHtml,useforforunordedlistsandfororderedlists:1)forunorderedlists,wrapitemsinanduseforeachItem,RenderingeringAsabulleTedList.2)fororderedlists,useandfornumberedlists,useandfornumberedlists,casundfornumberedlists,customeizableWithTheTtheTthetTheTeTeptTributeFordTributeForderForderForderFerentNumberingSnumberingStyls。

HTML用于构建结构清晰的网站。1)使用标签如、、定义网站结构。2)示例展示了博客和电商网站的结构。3)避免常见错误如标签嵌套不正确。4)优化性能通过减少HTTP请求和使用语义化标签。

toinsertanimageIntoanhtmlpage,usethetagwithsrcandaltattributes.1)usealttextforAcccessibilityandseo.2)instementRcsetForresponSiveImages.3)applylazyloadingWithLoadingWithLoading =“ lazy” tooptimizeperformance.4)tooptimizeperformance.4)

HTML的核心目的在于让浏览器理解并展示网页内容。1.HTML通过标签定义网页结构和内容,如、到、等。2.HTML5增强了多媒体支持,引入了和标签。3.HTML提供了表单元素,支持用户交互。4.优化HTML代码可提升网页性能,如减少HTTP请求和压缩HTML。

htmltagsareessentialforwebdevelopmentastheyandendenhancewebpages.1)heSdefinElayout,语义和互动性。2)SemantictagsiCtagSimproveCacsibilitieAndseo.3)pose poseriblesibilityAndseoandseo.3)poser


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

SublimeText3汉化版
中文版,非常好用

安全考试浏览器
Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

螳螂BT
Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。