作为一个前端攻城狮,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的简写就不说了,太简单了
不知道总结的好不好,若有错烦指出,谢谢!

HTMLISNOTAPROGRAMMENGUAGE; ITISAMARKUMARKUPLAGUAGE.1)htmlStructures andFormatSwebContentusingtags.2)itworkswithcsssforstylingandjavascript for Interactivity,增强WebevebDevelopment。

HTML是构建网页结构的基石。1.HTML定义内容结构和语义,使用、、等标签。2.提供语义化标记,如、、等,提升SEO效果。3.通过标签实现用户交互,需注意表单验证。4.使用、等高级元素结合JavaScript实现动态效果。5.常见错误包括标签未闭合和属性值未加引号,需使用验证工具。6.优化策略包括减少HTTP请求、压缩HTML、使用语义化标签等。

HTML是一种用于构建网页的语言,通过标签和属性定义网页结构和内容。1)HTML通过标签组织文档结构,如、。2)浏览器解析HTML构建DOM并渲染网页。3)HTML5的新特性如、、增强了多媒体功能。4)常见错误包括标签未闭合和属性值未加引号。5)优化建议包括使用语义化标签和减少文件大小。

WebDevelovermentReliesonHtml,CSS和JavaScript:1)HTMLStructuresContent,2)CSSStyleSIT和3)JavaScriptAddSstractivity,形成thebasisofmodernWebemodernWebExexperiences。

HTML的作用是通过标签和属性定义网页的结构和内容。1.HTML通过到、等标签组织内容,使其易于阅读和理解。2.使用语义化标签如、等增强可访问性和SEO。3.优化HTML代码可以提高网页加载速度和用户体验。

htmlisaspecifictypefodyfocusedonstructuringwebcontent,而“代码” badlyLyCludEslanguagesLikeLikejavascriptandPytyPythonForFunctionality.1)htmldefineswebpagertuctureduseTags.2)“代码”代码“ code” code code code codeSpassSesseseseseseseseAwiderRangeLangeLangeforLageforLogageforLogicIctInterract

HTML、CSS和JavaScript是Web开发的三大支柱。1.HTML定义网页结构,使用标签如、等。2.CSS控制网页样式,使用选择器和属性如color、font-size等。3.JavaScript实现动态效果和交互,通过事件监听和DOM操作。

HTML定义网页结构,CSS负责样式和布局,JavaScript赋予动态交互。三者在网页开发中各司其职,共同构建丰富多彩的网站。


热AI工具

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

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

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

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

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 英文版
推荐:为Win版本,支持代码提示!

SublimeText3 Linux新版
SublimeText3 Linux最新版