red#f00 / #ff0000rgb(255,0,0) / rgb(100%,0%,0%)| 屬性 | 作用 | 典型值 |
|---|---|---|
background-color | 背景顏色 | 同上色值 |
background-image | 背景圖片 | url(/path/img.png) |
background-repeat | 平鋪方式 | repeat-x、no-repeat |
background-attachment | 滾動行為 | scroll、fixed |
background-position | 起始位置 | center top、50px 10px、20% 50% |
background | 綜合簡寫 | #ffcc00 url(/bg.jpg) fixed center |
font-family:字體族列表,備選機制 "Microsoft JhengHei", "PingFang TC", sans-seriffont-style:normal、italic、obliquefont-variant:normal、small-caps(英文小型大寫)font-weight:normal/bold 或 100-900 數值font-size:絕對(xx-large)、相對(larger)、長度(16px、1.2rem)、百分比font:綜合簡寫,順序 style variant weight size/line-height family| 屬性 | 功能 | 關鍵值 |
|---|---|---|
letter-spacing | 字符間距 | 0.1em |
text-decoration | 修飾線 | underline、line-through |
vertical-align | 垂直對齊 | baseline、middle、sub/super |
text-transform | 大小寫轉換 | uppercase、capitalize |
text-align | 水平對齊 | left、center、justify |
text-indent | 首行縮進 | 2em、-9999px(隱藏文字) |
line-height | 行高 | 1.5、24px、150% |
list-style-type:有序 decimal/lower-roman,無序 disc/circle/squarelist-style-image:自定義圖標 url(/icon.png)list-style-position:outside(預設)、insidelist-style:綜合簡寫均遵循順時針順序:上 → 右 → 下 → 左。值數量對應規則:
| 屬性 | 說明 |
|---|---|
border | 綜合設定寬度、樣式、顏色:1px solid #333 |
width/height | 元素盒尺寸 |
float | 浮動佈局:left/right/none |
clear | 清除浮動:left/right/both |
z-index | 疊放層級,整數可負 |
visibility | visible/hidden/collapse |
熟練掌握上述核心屬性及其簡寫規則,是高效編寫、維護 CSS 的基礎。建議建立個人常用片段庫,結合現代 CSS 變量(Custom Properties)實現設計系統級的樣式管理。