DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> CSS入門知識 >> CSS詳解
CSS 屬性撰寫順序:一套可複用的排列慣例
編輯:CSS詳解     

整理了一下自己寫 CSS 時的屬性順序,貼出來參考。排列規則很簡單:由上而下、由左而右。同一行內的多個屬性以 || 分隔,代表可並列且順序可互換。

定位與層疊

display || visibility
list-style : list-style-type || list-style-position || list-style-image
position
top || right || bottom || left
z-index
clear
float

盒模型

width
max-width || min-width
height
max-height || min-height
overflow || clip
margin : margin-top || margin-right || margin-bottom || margin-left
padding : padding-top || padding-right || padding-bottom || padding-left
outline : outline-color || outline-style || outline-width
border
background : background-color || background-image || background-repeat || background-attachment || background-position

文字與內容

color
font : font-style || font-variant || font-weight || font-size || line-height || font-family
font : caption | icon | menu | message-box | small-caption | status-bar
text-overflow
text-align
text-indent
line-height
white-space
vertical-align
cursor

這套順序的核心邏輯是:先決定元素「是什麼、在哪裡」(顯示方式、定位、層級、浮動),再處理「有多大、怎麼排」(尺寸、間距、邊框、背景),最後才是「看起來如何」(色彩、字型、文字對齊與游標)。實際使用時可依團隊習慣微調,重點是全組採用同一套規則,讓任何人接手都能快速定位屬性。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved