萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 程式設計 >  >> 網頁製作 >> Div CSS 教學

CSS 屬性完整參考手冊:分類、語法與適用值

CSS 屬性分類速查表

本文整理了 CSS 核心屬性,按功能模組分類,列出屬性名稱、用途說明及常用值,方便開發快速查閱。

字體與文字屬性

屬性用途常用值
font-family設定字體族系Arial, "Microsoft YaHei", sans-serif 等
font-style字體風格normal, italic, oblique
font-variant小型大寫字母normal, small-caps
font-weight字體粗細normal, bold, bolder, lighter, 100-900
font-size字體大小px, em, rem, %, 關鍵字
color文字顏色十六進制, rgb(), hsl(), 關鍵字
text-align水平對齊left, right, center, justify
text-decoration文字裝飾none, underline, overline, line-through
text-indent首行縮進長度值, %
line-height行高數字, 長度, %, normal
letter-spacing字母間距長度值, normal
word-spacing單詞間距長度值, normal
text-transform大小寫轉換capitalize, uppercase, lowercase, none
vertical-align垂直對齊baseline, top, middle, bottom, sub, super

背景與邊框屬性

屬性用途常用值
background-color背景顏色顏色值, transparent
background-image背景圖片url(), none, gradient
background-repeat平鋪方式repeat, repeat-x, repeat-y, no-repeat
background-position背景定位關鍵字, %, 長度值
background-attachment背景固定/滾動scroll, fixed, local
background簡寫屬性依序: color image repeat attachment position
border-width邊框寬度thin, medium, thick, 長度值
border-style邊框樣式none, solid, dashed, dotted, double, groove...
border-color邊框顏色顏色值, transparent
border邊框簡寫width style color
border-radius圓角長度值, %

盒模型與佈局屬性

屬性用途常用值
width / height寬度/高度auto, 長度值, %
margin外邊距長度值, %, auto
padding內邊距長度值, %
display顯示類型block, inline, inline-block, flex, grid, none
position定位方式static, relative, absolute, fixed, sticky
top/right/bottom/left定位偏移長度值, %
float浮動left, right, none
clear清除浮動left, right, both, none
z-index堆疊順序整數, auto
overflow溢出處理visible, hidden, scroll, auto
box-sizing盒模型計算content-box, border-box

列表與游標屬性

屬性用途常用值
list-style-type列表項標記disc, circle, square, decimal, none
list-style-image自定義標記圖片url(), none
list-style-position標記位置inside, outside
cursor滑鼠游標樣式pointer, default, text, move, help, wait...

CSS3 新增重點屬性

  • Flexbox: flex, flex-direction, justify-content, align-items 等
  • Grid: grid-template-columns, grid-gap, grid-area 等
  • 動畫/過渡: transition, animation, @keyframes
  • 變形: transform, transform-origin
  • 陰影: box-shadow, text-shadow
  • 媒體查詢: @media

使用建議

  • 優先使用簡寫屬性(如 font, background, margin)減少代碼量。
  • 採用 border-box 盒模型(box-sizing: border-box)簡化佈局計算。
  • 善用 CSS 變數(自定義屬性)實現主題切換與維護。
  • 參考 MDN CSS 參考 獲取最新完整規範。
copyright © 萬盛學電腦網 all rights reserved