| 屬 性 名 稱(chēng) | 屬性功能及其取值 | 用 法 說(shuō) 明 與 范 例 |
| 顏色與背景類(lèi) | ||
| color | 設置文字顏色 #rgb #rrggbb rgb(255,255,255) rgb(100%,100%,100%) | H1{color:red} H1{color:#f00} H1{color:#ff0000} H1{color:rgb(255,0,0)} H1{color:rgb(100%,0%,0%)} |
| background-color | 設置背景顏色,格式同上。 | BODY{background-color:red} BODY{background-color:#f00} BODY{background-color:#ff0000} BODY{background-color:rgb(255,0,0)} BODY{background-color:rgb(100%,0%,0%)} |
| background-image | 設置背景圖片, url(/imageURL) | body{backround-image:url(/back.jpg);} |
| background-repeat | 設置背景圖片是否重復排列: repeat-x(X軸重復排列); repeat-y(Y軸重復排列); No-repeat(不重復排列) | BODY{background-repeat:repeat-x;} BODY{background-repeat:No-repeat;} |
| background-attachment | 設定背景圖片是否卷動(dòng),默認為卷動(dòng)。 scroll(卷動(dòng)) fixed(不卷動(dòng)) | BODY{background-attachment:fixed;} |
| background-position | 設定背景圖片或背景顏色開(kāi)始顯示的位置,取值格式: top,buttom,left,right,center(用關(guān)鍵字) 70px 10px(用長(cháng)度值) 50% 30%(用百分比) | BODY{background-position:right top;} BODY{background-position:50px 10px;} BODY{background-position:20% 50%;} |
| background | 定義背景綜合屬性,不要求順序,各屬性值以空格分開(kāi)。 | BODY{background:#ffcc00 url(/bg.jpg) fixed center} |
| 字型類(lèi) | ||
| font-family | 設置字型屬性,取值可以是任何字型名稱(chēng),缺省為瀏覽器內定字型,可以設多個(gè)以逗號(,)分開(kāi),有空格的英文字型可用單引號或雙引號括起來(lái)。 | P{font-family:宋體,楷體,黑體,"Time New Rom";} |
| font-style | 設定字型樣式:Normal(正常),italic、objlique(斜體) | P{font-style:italic;} |
| font-variant | 取值:Normal(默認),small-caps(如果是中文字型則將字型縮小顯示,如果是英文則全部改為較小的大寫(xiě)) | H3{font-variant:small-caps;} |
| font-weight | 設定字體粗細,取值有: Normal(默認),bold,lighter,border,100,200...900 由于瀏覽器支持程度不同,一般只用normal和bold兩種屬性。 | P{font-weight:bold;} |
| font-size | 設定字體的大??; 絕對大?。簒x-small,x-small,small,mediumlarge,x-large,xx-large; 相對大?。簂arger,smaller; 數字表示可用單位:磅(pt),像素(px),英寸(in),厘米(cm); 亦可用百分比表示。 | H2{font-size:36pt;} P{font-size:200%;} |
| font | 設定字型的綜合屬性,其順序如下: {font-style font-variant font-weight font-size /line-height font-family;} | P{bold 12pt/14pt impact,Arial;} |
| 文字類(lèi) | ||
| letter-spacing | 設定文字間距。 | P{letter-spacing:5pt;} |
| text-decoration | 設定文字加上下劃線(xiàn)、刪除線(xiàn)等效果: none(無(wú)) underline(下劃線(xiàn)) overline(上劃線(xiàn)) line-through(刪除線(xiàn)) | |
| vertical-align | 設定文字或圖片垂直方向的對齊方式: baseline:默認值 sub:下標 super:上標 top:垂直向上對齊 middle:垂直居中 bottom:垂直向下對齊。 | |
| text-transform | 轉換英文字母大小寫(xiě): none:默認值 capitalize:首字母大寫(xiě) uppercase:所有英文字母大寫(xiě) lowercase:所有英文字母小寫(xiě)。 | |
| text-align | 設置文字的水平對齊方式: left:左對齊 right:右對齊 center:水平居中 justify:左右對齊。 | |
| text-indent | 設定標記元素內文字的首行縮進(jìn)或配合margin-left屬性設定首行凸排。 | |
| line-height | 設定行高,聲明方式有標準行高、固定值表示法、百分比行高、字型大小比例行高等。 | |
| 列表類(lèi) | ||
| list-style-type | 有序列表的編號方式(供<OL>標記使用): none:無(wú)編號 decimal:阿拉伯數字 lower-roman:小寫(xiě)羅馬數字 upper-roman:大寫(xiě)羅馬數字 lower-alpha:小寫(xiě)英文字母 upper-alpha:大寫(xiě)英文字母。 | |
| list-style-type | 無(wú)序列表的符號樣式(供<UL>使用): none:無(wú)符號 disc:實(shí)心圓符號 circle:空心圓符號 square:實(shí)心方形符號。 | |
| list-style-image | 無(wú)序列表的自定義符號樣式: 格式:url(圖片名稱(chēng)) | UL{list-style-imag:url(/dd.gif);} |
| list-style-position | 設置列表清單符號縮排屬性: outside:凸排 inside:縮排 | UL{list-style-imag:url(/dd.gif); list-style-position:outside;} |
| list-style | 列表清單項目的綜合設定,屬性之間用空格隔開(kāi)。 | UL{list-style-imag:url(/dd.gif) inside;} |
| 邊界及其相關(guān)類(lèi) | ||
| margin | 標記元素邊界值的綜合設定。(其規則見(jiàn)右邊范例) 亦可以用margin-top、margin-right、margin-bottom、margin-left分開(kāi)設定各邊的邊界。 | 聲明4個(gè)值,其順序為上、右、下、左邊界,如:DIV{margin:12pt 15pt 20pt 16pt;} 聲明3個(gè)值,其順序為上、右、下,缺少的左邊界取其對邊(右),如:DIV{margin:12pt 15pt 16pt;} 聲明2個(gè)值,其順序為上、右,缺少的下、左邊界取其對邊,如:DIV{margin:12pt 15pt;} 聲明1個(gè)值,則4個(gè)邊界同一個(gè)值,如:DIV{margin:15pt;} |
| padding | 設定標記內容與標記邊框之間的留白的綜合設定(規則見(jiàn)margin屬性的范例)。 | 也可分開(kāi)設定padding-top、padding-right、padding-bottom、padding-left各值。 |
| border-width | 標記元素邊框寬度的綜合設定(規則類(lèi)似于margin屬性)。 | 也可分開(kāi)設定border-top-width、border-right-width、border-bottom-width、border-left-width各值。 |
| border-color | 標記元素邊框顏色的綜合設定(規則類(lèi)似于margin屬性)。顏色取值見(jiàn)color屬性。 | 也可分開(kāi)設定border-top-color、border-right-color、border-bottom-color、border-left-color各值。 |
| border-style | 標記元素邊框樣式的綜合設定(規則類(lèi)似于margin屬性)。邊框樣式有solid,double,goove,ridge,inset,outset等。 | 也可分開(kāi)設定border-top-style、border-right-style、border-bottom-style、border-left-style各值。 |
| border | 標記元素4個(gè)邊框的綜合設定,可以分別聲明邊框寬度、邊框樣式、和邊框顏色。 | DIV{border:5pt solid #ff0000;} |
| width | 設定標記元素的寬度。 | |
| height | 設定標記元素的高度。 | |
| float | 設定標記元素與文字間的相對位置(文字繞排方式)。取值: none:以默認方式顯示; left:標記元素靠左,文字在右邊繞排; right:標記元素靠右,文字在左邊繞排; | |
| clear | 設定標記元素與文字間的相對位置(與float不同的是標記元素兩邊都不繞排)。取值: none:以默認方式顯示; left:標記元素靠左,右邊無(wú)文字繞排; right:標記元素靠右,左邊無(wú)文字繞排; | |
| 其他類(lèi) | ||
| z-index | 設定標記元素的堆疊層次,取值為整數,也可以是負數,數值大的在上層。 | |
| visibility | 設定標記元素是否可見(jiàn),取值有: inherit:取默認值 visible:可見(jiàn) hidden:不可見(jiàn)(隱藏) |
聯(lián)系客服