Font 字体缩写
font: font-style | font-variant | font-weight | font-size | line-height | font-family
例: p{font:italic normal bold 12pt/18pt 宋体;}
不需要的参数可以用 normal 代替,因为CSS中各个属性的值写法并不是都相同,因此直接去掉某个参数不会影响顺序与值的关系.
本例中12pt/18pt指的是font-size字号与line-height行高,使用反斜杠分割因为font-size与line-height的值有可能使用同一计量单位,为了保证CSS对两个值所对应的属性一致,必须使用反斜杠来分割两个数值.
padding margin(上左下右)
margin: margin-top | margin-right | margin-bottom | margin-left
padding:padding-top | padding-right | padding-bottom | padding-left
p{margin:20px;} 单独使用一个参数,将表示P对象周围的外边距都为20px.
p{margin:20px 10px;}使用两个参数是非常特殊的写法,表示对上下或者左右的样式控制,当前样式表示p对象的上下边距为20px,而左右边距为10px.
p{margin:20px 10px 100px;}使用3个参数表示上边距为20px,左右边距为10px,下边距为100px.
p{margin:120px 20px 10px 80px;}4个参数则是margin属性的完整写法表示 top:120px right:20px bottom:10px left:80px
padding与margin设置方法完全相同
Border边框缩写
border: border-width | border-style | color
border-top(top,right,bottom,left):border-width | border-style | color
border-width(width,color,style):top | right | bottom | left
list缩写
list-style: list-style-type | list-style-position | list-style-image
例: ul{list-style:disc outside none;}
background背景缩写
background: background-color | background-image | background - repeat | background-attachment | background-pasition
例: #content{background:#EDEDED url(img/bg.gif) no-repeat 30% 20px;}