网络编程
位置:首页>> 网络编程>> 网页设计>> Web标准基础教程:CSS简写指南(3)

Web标准基础教程:CSS简写指南(3)

 来源:前端观察 发布时间:2010-04-02 12:47:00 

标签:CSS简写,缩写,web标准,教程,CSS优化

背景(background)

background是最常用的简写之一,它包含以下属性:


background-color: color || #hex || RGB(% || 0-255) || RGBa;
background-image:url();
background-repeat: repeat || repeat-x || repeat-y || no-repeat;
background-position: X Y || (top||bottom||center) (left||right||center);
background-attachment: scroll || fixed;


background的简写可以大大的提高css的效率:


background:#fff url(img.png) no-repeat 0 0;


background的简写也有些默认值:


background:transparent none repeat scroll top left ;


background属性的值不会继承,你可以只声明其中的一个,其它的值会被应用默认的。

font

font简写也是使用最多的一个,它也是书写高效的CSS的方法之一。

font包含以下属性:


font-style: normal || italic || oblique;
font-variant:normal || small-caps;
font-weight: normal || bold || bolder || || lighter || (100-900);
font-size: (number+unit) || (xx-small - xx-large);
line-height: normal || (number+unit);
font-family:name,"more names";


font的各个属性也都有默认值,记住这些默认值相对来说比较重要:


font-style: normal;
font-variant:normal;
font-weight: normal;
font-size: inherit;
line-height: normal;
font-family:inherit;


事实上,font的简写是这些简写中最需要小心的一个,稍有疏忽就会造成一些意想不到的后果,所以,很多人并不赞成使用font缩写。

不过这里正好有个小手册,相信会让你更好的理解font的简写:

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com