按 **功能分類** 整理,列出屬性名、核心取值、典型用例。完整屬性清單請參考 MDN CSS Reference。
| 屬性 | 核心取值 | 典型用例 |
|---|---|---|
color | #rrggbb, rgb(), hsl(), currentColor | 文字顏色、SVG fill 繼承 |
background-color | 同 color | 背景填充色 |
background-image | url(), linear-gradient(), radial-gradient(), conic-gradient() | 背景圖/漸變 |
background-size | cover, contain, 100% auto, auto 200px | 圖片縮放模式 |
background-position | center, top right, 50% 50% | 圖片定位 |
background-repeat | no-repeat, repeat-x, repeat-y, space, round | 平鋪控制 |
background-attachment | scroll, fixed, local | 視差/固定背景 |
background | 簡寫:color image repeat attachment position / size | 一行聲明完整背景 |
opacity | 0–1 | 元素整體透明度 (含子元素) |
| 屬性 | 核心取值 | 典型用例 |
|---|---|---|
font-family | 字體名列表, system-ui, serif, sans-serif, monospace | 字體棧定義 |
font-size | rem, em, px, clamp() | 響應式字級 |
font-weight | 100–900, normal, bold | 粗細控制 |
font-style | normal, italic, oblique | 斜體 |
line-height | 1.5 (無單位推薦), 1.5rem | 行高/垂直節奏 |
font | 簡寫:style variant weight size/line-height family | 一行全設 |
text-align | left, center, right, justify | 水平對齊 |
text-decoration | none, underline, line-through, overline | 下劃線/刪除線 |
text-transform | uppercase, lowercase, capitalize | 大小寫轉換 |
white-space | normal, nowrap, pre, pre-wrap | 空白/換行處理 |
text-overflow | ellipsis, clip | 溢出省略號 (配合 overflow/white-space) |
vertical-align | baseline, middle, top, bottom, sub, super | 行內/表格單元格垂直對齊 |
| 屬性 | 核心取值 | 典型用例 |
|---|---|---|
width/height | auto, 100%, 500px, min()/max()/clamp() | 尺寸控制 |
min-/max-width/height | 同上 | 尺寸約束 |
box-sizing | border-box (推薦全局), content-box | 盒模型計算模式 |
margin | 長度、百分比、auto | 外邊距、水平居中 |
padding | 長度、百分比 | 內邊距 |
border | 簡寫:width style color | 邊框一行全設 |
border-radius | 50%, 8px, 8px 16px, 8px/16px | 圓角/橢圓 |
display | block, inline, inline-block, flex, grid, none, table... | 佈局模式切換 |
position | static, relative, absolute, fixed, sticky | 定位模式 |
top/right/bottom/left | 長度、百分比、auto | 定位偏移 |
z-index | 整數 (可負) | 層疊順序 |
float | left, right, none | 浮動 (僅文字環繞場景) |
clear | left, right, both, none | 清除浮動 |
overflow | visible, hidden, scroll, auto, clip | 溢出處理、BFC 觸發 |
| 屬性 | 核心取值 | 說明 |
|---|---|---|
list-style-type | disc, decimal, none, cjk-ideographic... | 標記類型 |
list-style-image | url(), none | 圖片標記 (現代用 ::marker) |
list-style-position | outside, inside | 標記位置 |
list-style | 簡寫:type position image | 一行全設 |
::marker | 偽元素,支援 content, color, font-size... | 現代標記完全控制 |
| 屬性 | 核心取值 | 典型用例 |
|---|---|---|
box-shadow | x y blur spread color, 多層逗號分隔 | 陰影、描邊模擬 |
text-shadow | x y blur color | 文字陰光/描邊 |
filter | blur(), brightness(), grayscale(), drop-shadow() | 圖片/元素濾鏡 |
transform | translate(), rotate(), scale(), skew() | 2D/3D 變換、動畫核心 |
transition | property duration timing-function delay | 狀態過渡動畫 |
animation | name duration timing-function delay iteration-count direction fill-mode | 關鍵幀動畫 |
clip-path | polygon(), circle(), ellipse(), inset() | 裁切形狀、三角形、不規則區域 |
mask | image, gradient, repeat, position... | 遮罩、非矩形顯示 |
box-sizing: border-box — 統一盒模型認知rem/em/clamp() 相對單位 — 響應式、無障礙縮放友好transform/opacity — 觸發合成器線程,60fps 穩定margin-inline/padding-block — 原生支援 RTL/LTR此速查表覆蓋 90%+ 日常開發用到的 CSS 屬性。建議:**收藏本文、配合 MDN 深入查閱、建立團隊常用片段庫 (VS Code Snippets)**。屬性記不全不可怕,**會分類查找、理解渲染原理、遵循現代最佳實踐** 才是核心競爭力。