CSS简写

1.颜色的简写

4种表现:

color:#FF000;(RR/GG/BB三组颜色值成对,可简写为#F00)

color:RGB(255,0,0);/ color:RGB(100%,0,0);

color:red;

color:windowtext;background-color:background;(用户系统色盘值) 

2.padding和margin上右下左的简写
3.border的简写

border-width:1px;

border-style:solid;

border-color:red;

上面可简写为:

border:1px solid red;

4.background的简写

background-color:red;

background-image:url(background.jpg);

background-repeat:no-repeat;

background-attachment:fixed;

background-position:0 0;

上面可简写为:

background:red url(background.jpg) no-repeat fixed 0 0;

background属性默认值为:

background-color:transparent;

background-image:none;

background-repeat:no-repeat;

background-attachment:scroll;

background-position:0% 0%;

5.font的简写

font-style:italic;

font-variant:small-caps;

font-weight:bold;

font-size:12px;

line-height:140%;

font-family:”LucidaGranda”,sans-serif;

上面可简写为:

font:italicsmall-caps bold 12px/140% “Lucida Granda”,sans-serif;

font属性默认值为:

font-style:normal;

font-variant:normal;

font-weight:normal;

font-size:medium;

line-height:normal;

font-family:”TimesNew Roman”;

6.ul和ol表的简写

li{

    list-style-image:url(background.jpg);

    list-style-position:inside;

    list-style-type:square;

}

可以简写为:

li{

    list-style:url(background.jpg)inside square;

}

系统默认值为:

list-style-image:none;

list-style-position:outside;

list-style-type:disc;


注:上面内容引自《CSS那些事这本书》

猜你喜欢

转载自blog.csdn.net/qq_36164306/article/details/81037986
今日推荐