帖子浏览
|
用户名:小西 用户ID:1 用户级别:17管理员 注册时间:2006-08-10 论坛分数:32445 |
转:常用CSS缩写语法总结使用缩写可以帮助减少你CSS文件的大小,更加容易阅读。css缩写的主要规则如下:<br/><br/>颜色<br/>16进制的色彩值,如果每两位的值相同,可以缩写一半,例如:<br/>#000000可以缩写为#000;#336699可以缩写为#369;<br/><br/>盒尺寸<br/>通常有下面四种书写方法:<br/><br/>property:value1; 表示所有边都是一个值value1; <br/>property:value1 value2; 表示top和bottom的值是value1,right和left的值是value2 <br/>property:value1 value2 value3; 表示top的值是value1,right和left的值是value2,bottom的值是value3 <br/>property:value1 value2 value3 value4; 四个值依次表示top,right,bottom,left <br/>方便的记忆方法是顺时针,上右下左。具体应用在margin和padding的例子如下:<br/>margin:1em 0 2em 0.5em; <br/><br/>边框(border)<br/>边框的属性如下:<br/><br/>border-width:1px; <br/>border-style:solid; <br/>border-color:#000; <br/>可以缩写为一句:border:1px solid #000; <br/><br/>语法是border:width style color; <br/><br/>背景(Backgrounds)<br/>背景的属性如下:<br/><br/>background-color:#f00; <br/>background-image:url(background.gif); <br/>background-repeat:no-repeat; <br/>background-attachment:fixed; <br/>background-position:0 0; <br/>可以缩写为一句:background:#f00 url(background.gif) no-repeat fixed 0 0; <br/><br/>语法是background:color image repeat attachment position;<br/><br/>你可以省略其中一个或多个属性值,如果省略,该属性值将用浏览器默认值,默认值为:<br/><br/>color: transparent <br/>image: none <br/>repeat: repeat <br/>attachment: scroll <br/>position: 0% 0% <br/>字体(fonts)<br/>字体的属性如下:<br/><br/>font-style:italic; <br/>font-variant:small-caps; <br/>font-weight:bold; <br/>font-size:1em; <br/>line-height:140%; <br/>font-family:"Lucida Grande",sans-serif; <br/>可以缩写为一句:font:italic small-caps bold 1em/140% "Lucida Grande",sans-serif;<br/><br/>注意,如果你缩写字体定义,至少要定义font-size和font-family两个值。<br/><br/>列表(lists)<br/>取消默认的圆点和序号可以这样写list-style:none;,<br/><br/>list的属性如下:<br/><br/>list-style-type:square; <br/>list-style-position:inside; <br/>list-style-image:url(image.gif); <br/>可以缩写为一句:list-style:square inside url(image.gif);
个人签名:
我的签名测试 |
本主题讨论树
-
转:CSS十大密技
(4112字)
【小西】
2006-09-22 19:17
阅读:86
-
转:CSS Hack 浏览器兼容一览表
(95字)
【小西】
2006-09-22 19:19
阅读:89
-
转:CSS的十八般技巧
(7014字)
【小西】
2006-09-22 19:25
阅读:80
-
转:常用CSS缩写语法总结
(1757字)
【小西】
2006-09-22 19:26
阅读:139
-
回复本帖
请先 登录,再回复本帖。