盒模型代码缩写
盒模型的外边距(margin)、内边距(padding)和边框(border)属性需要对四个方向分别设置时,一般按照顺时针方向:上右下左。如:margin:10px 15px 12px 14px;
以下三种情况可以进行缩写:
(1)top、right、bottom、left的值相同,可缩写为:margin:10px;
(2)top和bottom值相同、left和 right的值相同,可缩写为:
margin:10px 20px;
(3)left和right的值相同,可缩写为:
margin:10px 20px 30px;
颜色值缩写
对于16进制色彩值,如果每两位的值相同,可以缩写一半。如,color:#336699;
可以缩写为color: #369;
。字体缩写
可以将:body{ font-style:italic; font-variant:small-caps; font-weight:bold; font-size:12px; line-height:1.5em; font-family:"宋体",sans-serif; }
缩写为:
body{ font:italic small-caps bold 12px/1.5em "宋体",sans-serif; }
使用这种方式必须:
(1)至少要指定 font-size 和 font-family 属性。其它属性未指定时将使用默认值;
(2)缩写时 font-size 与 line-height 中间要加入“/”斜扛。对于中文网站下面的缩写代码比较常用:
``` body{ font:12px/1.5em "宋体",sans-serif; } ```
包括字号、行间距、中文字体、英文字体的设置。
CSS代码缩写
最新推荐文章于 2022-04-27 15:34:10 发布