应用缩写能够协助降低你CSS文档的尺寸,更为非常容易阅读文章。css缩写的关键标准以下:
色调
16进制的颜色值,假如每两位的值同样,能够缩写1半,比如:
#000000能够缩写为#000;#336699能够缩写为#369;
盒规格
一般有下面4种撰写方式:
property:value1; 表明全部边全是1个值value1;
property:value1 value2; 表明top和bottom的值是value1,right和left的值是value2
property:value1 value2 value3; 表明top的值是value1,right和left的值是value2,bottom的值是value3
property:value1 value2 value3 value4; 4个值先后表明top,right,bottom,left
便捷的记忆力方式是顺时针,上右下左。实际运用在margin和padding的事例以下:
margin:1em 0 2em 0.5em;
边框(border)
边框的特性以下:
border-width:1px;
border-style:solid;
border-color:#000;
能够缩写为1句:border:1px solid #000;
英语的语法是
border:width style color;
情况(Backgrounds)
情况的特性以下:
background-color:#f00;
background-image:url(background.gif);
background-repeat:no-repeat;
background-attachment:fixed;
background-position:0 0;
能够缩写为1句:background:#f00 url(background.gif) no-repeat fixed 0 0;
英语的语法是
background:color image repeat attachment position;
你能够省略在其中1个或好几个特性值,假如省略,该特性值将用访问器默认设置值,默认设置值为:
color: transparent
image: none
repeat: repeat
attachment: scroll
position: 0% 0%
字体样式(fonts)
字体样式的特性以下:
font-style:italic;
font-variant:small-caps;
font-weight:bold;
font-size:1em;
line-height:140%;
font-family:"Lucida Grande",sans-serif;
能够缩写为1句:font:italic small-caps bold 1em/140% "Lucida Grande",sans-serif;
留意,假如你缩写字体样式界定,最少要界定font-size和font-family两个值。
目录(lists)
撤销默认设置的圆点和编号能够这样写list-style:none;,
list的特性以下:
list-style-type:square;
list-style-position:inside;
list-style-image:url(image.gif);
能够缩写为1句:list-style:square inside url(image.gif);