標籤:style blog http color ar 使用 strong sp div
盒子大小
這裡主要用於兩個屬性:margin和padding,我們以margin為例,padding與之相同。盒子有上下左右四個方向,每個方向都有個外邊距:
縮寫的順序是上->右->下->左。順時針的方向。相對的邊的值相同,則可以省掉:
margin:1px;//四個方向的邊距相同,等同於margin:1px 1px 1px 1px;margin:1px 2px;//上下邊距都為1px,左右邊距均為2px,等同於margin:1px 2px 1px 2pxmargin:1px 2px 3px;//右邊距和左邊距相同,等同於margin:1px 2px 3px 2px;margin:1px 2px 1px 3px;//注意,這裡雖然上下邊距都為1px,但是這裡不能縮寫。
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的簡寫:
參考:
常用CCS文法總潔
前端觀察
CSS技巧(三):CSS經常忘記兩個簡寫