好的程序员web前端分享css常用属性的缩写,使用缩写可以帮助减少你的CSS文件的大小并使其更容易阅读。css缩写的主要规则如下: color 16个颜色值,如果每两个数字的值相同,则可以缩写一半,例如: #000000可以缩写到#000;#336699可以简写For#369; boxsize 通常有以下四种写法: property:value1;表示所有边都是一个值value1; 属性:值1值2;表示top和bottom的值为value1,right和left的值为value2 property:value1value2value3;表示top的值为value1,right和left的值为value2,bottom的值为value3 property:value1value2value3value4; 这四个值依次代表top,right,bottom,left 方便的记忆方法是顺时针,右上左下。margin和padding的具体应用示例如下: margin:1em02em0.5em; border(边框) border属性如下: border-width:1px;1.
border-style:solid;
2.
border-color:#000;
2.
border-color:#000;
font> 简化为一句话:border:1pxsolid#000; 语法为border:width样式颜色; 背??景(Backgrounds) 背景的属性如??下: background-color:#f00;1.
background-image:url(background.gif);
2.
background-repeat:no-repeat;
3.
background-attachment:fixed;
4.
background-position:00;
缩短为一句话:background:#f00url(background.gif)no-repeatfixed00; 语法为background:colorimagerepeatattachmentposition; 可以省略一个或多个属性值,如果省略,属性值将使用浏览器的默认值,默认值为: 颜色:透明1.
图像:无
2.
repeat:重复
3.
附件:滚动
4.
位置:0%0%
字体(fonts) 字体属性如下: font-style:italic;1.
font-variant:small-caps;
2.
font-weight:bold;
3.
font-size:1em;
4.
line-height:140%;
5.
font-family:"LucidaGrande",sans-serif;
可以简写成一句话:font:italicsmall-capsbold1em/140%"LucidaGrande",sans-serif; 规则一:必须声明font-size和font-family的值。规则二:所有值必须按照以下顺序声明。 1。font-weight,font-style,font-variant无特定顺序; 2。然后是字体大小; 3。最后是字体系列。 注意,如果缩写字体定义,至少要定义font-size和font-family的两个值。 lists(列表) 取消默认的点和序号可以这样写list-style:none; list属性如下: list-style-type:square;1.
list-style-position:inside;/p>2. list-style-image:url(image.gif);
可以简写成一句话:list-style:squareinsideurl(image.gif);