CSS 样式简写
在CSS中有许多简写的样式,它们被广泛使用。简写最好按照如下顺序进行书写
font
font: font-style font-weight font-size/line-height font-family
font-style
italic//斜体
normal//正常字体(默认)
font-weight
一般填写数字
400 normal(默认值)
700 bold(默认值)
font-size
16px(默认值)
font-family
直接填写字体名称即可如 `MicroSoft Yahei`
如
div{font: italic 700 14px/20px 'Microsoft Yahei';
}
注意 不需要的属性可以省略(取默认值),但是必须保留font-size和font-family属性,否则font属性将不会生效
background
background: background-color background-image background-repeat background-attachment background-position
背景颜色 背景图片 背景平铺 背景固定 背景图片位置
如
background: transparent url(images/male.png) no-repeat center center;
同样的对于你不需要的属性可以省略不写
border
border: border-width border-style border-color
如
border: 1px solid red;
表格
<table><thead> //表明是表头<tr> //一行<th>姓名</th> //一个单元格<th>性别</th><th>电话</th></tr></thead><tbody> //非表头部分<tr><td>李白</td><td>男</td><td>18681282718</td></tr><tr><td>小美</td><td>女</td><td>15228578292</td></tr></tbody></table>