CSS属性简写

  • 盒模型简写:

  1. 如果top、right、bottom、left的值相同,如下面代码:margin:10px 10px 10px 10px; 缩写为:margin:10px;

  2. 如果top和bottom值相同、left和 right的值相同。margin:10px 20px 10px 20px;缩写为:margin:10px 20px;

  3. 如果left和right的值相同.margin:10px 20px 30px 20px;缩写为:margin:10px 20px 30px;

  • 颜色值缩写

  1. p{color:#336699;} 缩写为:p{color:#369;}

  • 字体缩写

  1. 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 属性,其他的属性(如 font-weight、font-style、font-varient、line-height)如未指定将自动使用默认值。

2、在缩写时 font-size 与 line-height 中间要加入“/”斜扛。

原文地址:https://www.cnblogs.com/qinbb/p/5910686.html