DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> CSS入門知識 >> CSS詳解
CSS 屬性速查表:模板自定義必備知識
編輯:CSS詳解     

下表整理最常用的 CSS 屬性及其主要功能,適合經常需要自定義模板、又不想反覆翻書的人隨手查閱。

顏色與背景類

  • color:設置文字顏色。取值 #rgb、#rrggbb、rgb(255,0,0)、rgb(100%,0%,0%)。示例 H1{color:#f00}
  • background-color:設置背景顏色,取值格式同上。示例 BODY{background-color:#ff0000}
  • background-image:設置背景圖片,url(圖片路徑)。示例 body{background-image:url(/back.jpg);}
  • background-repeat:背景圖是否重複。repeat-x(X 軸)、repeat-y(Y 軸)、no-repeat(不重複)
  • background-attachment:背景是否隨滾動移動。默認 scroll(滾動),fixed(固定)
  • background-position:背景起始位置。可用關鍵字 top/bottom/left/right/center、長度值 50px 10px 或百分比 20% 50%
  • background:綜合設置,順序不敏感,各值以空格分隔。示例 BODY{background:#ffcc00 url(/bg.jpg) fixed center}

字型類

  • font-family:字型名稱,可多個以逗號分隔,含空格的英文名用引號括起。示例 P{font-family:宋體,楷體,"Times New Roman";}
  • font-style:normal、italic、oblique(斜體)
  • font-variant:normal 或 small-caps(小型大寫字母)
  • font-weight:粗細,normal、bold、lighter、bolder 或 100~900 的數值。實務中主要用 normal 與 bold
  • font-size:字型大小。絕對關鍵字 xx-small~xx-large;相對關鍵字 larger、smaller;單位 pt、px、in、cm、em;或百分比
  • font:綜合設置,順序為 font-style font-variant font-weight font-size/line-height font-family。示例 P{font:bold 12pt/14pt impact,Arial;}

文字類

  • letter-spacing:字符間距,如 P{letter-spacing:5pt;}
  • text-decoration:none、underline、overline、line-through
  • vertical-align:垂直對齊,baseline(默認)、sub、super、top、middle、bottom、text-top、text-bottom
  • text-transform:none、capitalize(首字母大寫)、uppercase、lowercase
  • text-align:left、right、center、justify
  • text-indent:首行縮進,可配合負值做凸排
  • line-height:行高,可為標準值、固定長度、百分比或無單位倍數(推薦)

列表類

  • list-style-type:有序表編號 decimal、lower-roman、upper-roman、lower-alpha、upper-alpha、none;無序表符號 disc、circle、square、none
  • list-style-image:自定義符號圖片,url(圖片)
  • list-style-position:outside(凸排)、inside(縮排)
  • list-style:綜合設置,各值以空格分隔

邊界與盒子類

  • margin:外边距綜合設置。四值依次為上右下左;三值為上、右下、左取右;兩值為上下、左右;一值為四邊
  • padding:內邊距,規則同 margin,但不接受負值
  • border-width / border-color / border-style:邊框寬度、顏色、樣式的綜合設置,規則類似 margin;樣式可取 solid、double、groove、ridge、inset、outset
  • border:四邊框綜合設置,如 DIV{border:5pt solid #ff0000;}
  • width / height:元素寬度與高度
  • float:文字繞排。none(默認)、left(元素靠左,文字在右側繞排)、right(反之)
  • clear:清除繞排。none、left(左側不允許浮動元素)、right、both

其他常用

  • z-index:堆疊層次,整數可為負,數值大的在上層(僅對定位元素生效)
  • visibility:inherit、visible、hidden(隱藏但保留占位)
  • overflow:visible、hidden、scroll、auto,控制溢出內容的處理方式
  • display:block、inline、inline-block、none、flex、grid 等
  • position:static、relative、absolute、fixed、sticky

這份清單只覆蓋入門與日常所需。CSS 屬性持續擴充(Grid、Flexbox、容器查詢、自定義屬性等),遇到具體問題時查閱最新規範永遠比背表格可靠。

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