CSS 快速參考

下面按字母順序列出了所有的 CSS 屬性和對應的 DHTML 特性(所謂 DHTML 特性是指在客戶端腳本中引用該 CSS 屬性時使用的名稱),並對常用的屬性作了較詳細的說明,供讀者在設計網頁時參考。

CSS 屬性

DHTML 特性

說明

background background 提供多個背景屬性的組合。例如:BODY{background: no-repeat yellow left center url(./image/background.jpg)}
 background-attachment backgroundAttachment  指定特定 HTML 元素背景圖案是否與內容一起滾動,取值爲 scroll | fixed。默認值 scroll 表示背景圖案隨着內容一起滾動;fixed 表示背景圖案靜止,而內容可以滾動。例如:BODY{background-attachment:fixed}
background-color backgroundColor 指定特定 HTML 元素的背景顏色,取值爲 transparent 或具體顏色值。例如,H1{background-color:gray}
background-image backgroundImage 指定特定 HTML 元素的背景圖案,取值爲none | url(imageurl)(在指定其他有關背景圖案的屬性時,應先指定此屬性)。例如,H1{background-image:url(./MM.jpg)}
background-position backgroundPosition 指定特定 HTML 元素背景圖案的位置,取值爲由空格隔開的兩個值,既可以使用關鍵字 left | center | right 和 top | center | bottom,也可以指定百分數值,或者指定以標準單位計算的距離。例如:BODY{ background-position:left center}
background-repeat backgroundRepeat 指定特定 HTML 元素背景圖案是否重複,取值爲 repeat | repeat-x | repeat-y | no-repeat
border border 一次性指定四個框線的寬度、樣式和顏色。例如,H1{border:thin solid blue}
border-bottom borderBottom 指定邊框底邊的寬度、樣式和顏色。例如,H1{border-top:thin solid blue}
border-bottom-color borderBottomColor 指定邊框底邊的顏色,取值可以是任意顏色值
border-bottom-style borderBottomStyle 指定邊框底邊的樣式,取值可以是:none | dotted | dashed | solid |double | groove | ridge | inset | outset,默認值是 none
border-bottom-width borderBottomWidth 指定邊框底邊的寬度,取值可以是:thin | medium | thick 或長度值
 border-color  borderColor 設置邊框的顏色,取值可以是任意顏色值。可以指定多個值,按上、右、下、左的順序指定邊框的顏色,如果指定了 2 或 3 個值,則未指定顏色的邊框採用相對邊框的顏色值
border-left borderLeft 指定邊框左邊的寬度、樣式和顏色。例如,H1{border-left:thin solid blue}
border-left-color borderLeftColor 指定邊框左邊的顏色,取值可以是任意顏色值
border-left-style borderLeftStyle 指定邊框左邊的樣式,取值可以是:none | dotted | dashed | solid |double | groove | ridge | inset | outset,默認值是 none
border-left-width borderLeftWidth 指定邊框左邊的寬度,取值可以是:thin | medium | thick 或長度值
border-right borderRight 指定邊框右邊的寬度、樣式和顏色。例如,H1{border-right:thin solid blue}
border-right-color borderRightColor 指定邊框右邊的顏色,取值可以是任意顏色值
border-right-style borderRightStyle 指定邊框右邊的樣式,取值可以是:none | dotted | dashed | solid |double | groove | ridge | inset | outset,默認值是 none
border-right-width borderRightWidth 指定邊框右邊的寬度,取值可以是:thin | medium | thick 或長度值
border-style borderStyle 設置邊框的樣式,取值可以是:none | dotted | dashed | solid |double | groove | ridge | inset | outset,默認值是 none。當取多個值時,也按上、右、下、左的順序爲四個邊框設置不同的樣式;如果指定了 2 或 3 個值,則未指定樣式的邊框採用相對邊框的樣式值
border-top borderTop 指定邊框頂邊的寬度、樣式和顏色。例如,H1{border-top:thin solid blue}
border-top-color borderTopColor 指定邊框頂邊的顏色,取值可以是任意顏色值
border-top-style borderTopStyle 指定邊框頂邊的樣式,取值可以是:none | dotted | dashed | solid |double | groove | ridge | inset | outset,默認值是 none
border-top-width borderTopWidth 指定邊框頂邊的寬度,取值可以是:thin | medium | thick 或長度值
bottom bottom 確定元素下方向的位置
clear clear 指定元素是否允許浮動元素在它旁邊,取值可以是:none | left | right | both,默認值爲none
 border-width borderWidth  此屬性是設置 border-top-width、border-right-width、border-bottom-width、和border-left-width 的快捷方式(以此給定順序,即上、右、下、左的順序)。如果只給定一個值,則它應用於所有四個邊框線。如果給定 2 或 3 個值,則未指定的邊框採用與其相對邊框的設置
clip clip 控制元素的剪切
color color 指定特定 HTML 元素內文本的顯示顏色,取值爲任何合法的顏色值。例如,以下定義都是正確的:H1.red {color:red}、H1.red {color:#F00}、H1.red {color:#FF0000}、H1.red {color:rgb(255,0,0)}、H1.red {color:rgb(100%,0,0)}
cursor cursor 控制鼠標指針的樣式,取值可以是 auto | crosshair | default | hand | move | e-resize | ne-resize | nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | text | wait | help。例如,P{cursor:hand}
display display 確定元素是否應繪製在頁面上,取值可以是 block | inline | list-item | none
float styleFloat 指定元素在何處浮動,取值爲:none | left | right,默認值爲 none
font font 提供多個字體屬性的組合,按以下順序定義:font-weight,font-variant,font-style,font-size,line-height,屬性可以省略。例如,P{font:italic 200% serif}
font-family fontFamily 描繪要使用的“字體”優先級序列,取值可以是字體名稱,也可以是字體族名稱,值之間用逗號分隔。例如:BODY{font-family:gill,helvetica,sans-serif}
font-size fontSize 指定所用字體的大小,取值爲 xx-small | x-small | small | medium | large |x-large | xx-large | smaller | larger,或者是具體的長度值或百分比
font-style fontStyle 指定選定字體的樣式,取值爲 normal | italic | oblique,後兩者表示斜體。例如:H4 {font-style: italic}
font-variant fontVariant 選擇正常或小寫變體,取值爲 normal | small-caps
font-weight fontWeight 指定所用字體的粗細,取值爲 normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
height height 指定元素的高度
left left 確定元素左方向的位置
letter-spacing letterSpacing 指定文本字母間的間距,取值爲 normal 或具體的長度值。例如:P{letter-spacing:1mm}
line-height lineHeight 指定目標選項內文本的行高,取值可以是數字、長度或百分比,默認值是 normal。例如,DIV{line-height:1.5}
link link 控制鏈接的顏色
list-style listStyle 一次性指定列表項目標記的圖片、類型和位置。例如,UL{list-style:url(./image/ball.gif) disc inside}
list-style-image listStyleImage 爲列表指定圖片作爲項目標記,取值可以是none | url(imageurl)。例如,UL{list-style-image:url (./target.gif)}
list-style-position listStylePosition 指定列表項目標記的位置,取值可以是 inside 或 outside,默認值是outside
list-style-type listStyleType 指定列表項目標記的類型,取值可以是 disc | circle | square | decimal | lower-roman | upper-roman | lower-alpha | upper-alpha | none。例如,OL{list-style-type:lower-roman}
margin margin 指定邊界寬度的簡捷方式,可同時指定上、右、下、左(以此順序)邊界的寬度。如果只指定一個值,則四個方向都採用相同的邊界寬度;如果指定了 2 或 3 個值,則沒有指定邊界寬度的邊採用對邊的邊界寬度。例如,P{margin: 20px,0px}
margin-bottom marginBottom 設置底端邊界的寬度,取值可以是長度、百分比或 auto
margin-left marginLeft 設置左端邊界的寬度,取值可以是長度、百分比或 auto
margin-right marginRight 設置右端邊界的寬度,取值可以是長度、百分比或 auto
margin-top marginTop 設置頂端邊界的寬度,取值可以是長度、百分比或 auto
overflow overflow 控制元素內容越界時的處理
padding paddingTop 指定填充的簡捷方式,可同時指定上、右、下、左四個方向(以此順序)填充的寬度。如果只指定一個值,則四個方向都採用相同的填充寬度;如果指定了 2 或 3 個值,則沒有指定填充寬度的邊採用對邊的填充寬度。例如,P{padding:0.25in, 0.1in}
padding-bottom width 設置底端填充,取值可以是長度和百分數,但不允許使用負值
padding-left paddingLeft 設置左端填充,取值可以是長度和百分數,但不允許使用負值
padding-right paddingRight 設置右端填充,取值可以是長度和百分數,但不允許使用負值
 padding-top paddingTop  設置頂端填充,取值可以是長度和百分數,但不允許使用負值
page-break-after pageBreakAfter 設置在元素後是否出現頁分隔符
page-break-before pageBreakBefore 設置在元素前是否出現頁分隔符
position position 確定元素的定位方式,取值可以是 static | relative | absolute,默認值爲 static
right right 確定元素右方向的位置
text-align textAlign 指定目標選項內文本的對齊方式,取值是:left | right | center | justify。例如:P{text-align:justify}
text-decoration textDecoration 對文本施加修飾效果,取值爲none | underline | overline | line-through | blink。例如,:link, :visited, :active{text-decoration:none}
text-indent textIndent 按指定數值縮進文本,取值可以是長度值或百分比,默認值是 0。例如,P{text-indent:.74cm}
text-transform textTransform 對文本進行大小寫轉換,取值爲:capitalize|uppercase|lowercase|none,默認值是 none。capitalize 值指示所選元素中文本的每個單詞的首字母爲大寫;uppercase 值指示所有的文本都爲大寫,lowercase 值指示所有文本都以小寫顯示。例如,P{text-transform:uppercase}
top top 確定元素上方向的位置
unicode-bidi unicodeBidi 確定與雙向運算法則相關的嵌入層
vertical-align verticalAlign 確定垂直方向上的對齊,取值爲 baseline | sub | super | top | text-top | middle | bottom | text-bottom 或百分比。例如,IMG{vertical-align:text-top}
visibility visibility 確定定位的元素是否可見,取值可以是 inherit | visible | hidden,默認值是 inherit
width width 指定元素的寬度
word-spacing wordSpacing 指定單詞之間的額外間距,取值爲 normal 或長度值
z-index zIndex 控制元素的堆疊,取值爲整數,也可以是負數,數值越大,越在上層

----------[ HTML(CSS) ]----------

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章