| 屬性 | 功能 | 值範例 |
|---|---|---|
color | 文字顏色 | red, #f00, #ff0000, rgb(255,0,0), rgb(100%,0%,0%) |
background-color | 背景顏色 | 同 color 格式 |
background-image | 背景圖片 | url(/bg.jpg) |
background-repeat | 平鋪方式 | repeat, repeat-x, repeat-y, no-repeat |
background-attachment | 固定/捲動 | scroll, fixed |
background-position | 起始位置 | top left, 50% 50%, 10px 20px |
background | 綜合簡寫 | #ffcc00 url(/bg.jpg) fixed center |
| 屬性 | 功能 | 值範例 |
|---|---|---|
font-family | 字體家族 | Arial, "Microsoft YaHei", sans-serif |
font-style | 斜體 | normal, italic, oblique |
font-variant | 小型大寫 | normal, small-caps |
font-weight | 粗細 | normal, bold, 100-900 |
font-size | 大小 | 12px, 1em, 120%, large |
font | 綜合簡寫 | italic small-caps bold 12px/1.5 "Arial", sans-serif |
| 屬性 | 功能 | 值範例 |
|---|---|---|
letter-spacing | 字間距 | 2px, 0.1em |
text-decoration | 裝飾線 | none, underline, overline, line-through |
vertical-align | 垂直對齊 | baseline, sub, super, top, middle, bottom |
text-transform | 大小寫轉換 | capitalize, uppercase, lowercase, none |
text-align | 水平對齊 | left, right, center, justify |
text-indent | 首行縮進 | 2em, 24px |
line-height | 行高 | 1.5, 24px, 150% |
| 屬性 | 功能 | 值範例 |
|---|---|---|
list-style-type | 有序/無序符號 | disc, circle, square, decimal, lower-roman, none |
list-style-image | 自訂圖片符號 | url(/bullet.png) |
list-style-position | 符號位置 | outside, inside |
list-style | 綜合簡寫 | disc inside, url(/dot.png) outside |
| 屬性 | 功能 | 值規則 |
|---|---|---|
margin | 外邊距 | 1~4 值:上右下左 / 上、左右、下 / 左右、上下 / 四邊同值 |
padding | 內邊距 | 同 margin 規則 |
border-width | 邊框寬度 | 同 margin 規則 |
border-color | 邊框顏色 | 同 margin 規則 |
border-style | 邊框樣式 | solid, dashed, dotted, double, groove, ridge, inset, outset, none |
border | 綜合簡寫 | 1px solid #ccc(寬度 樣式 顏色) |
width / height | 寬/高 | auto, 長度值, 百分比 |
| 屬性 | 功能 | 值 |
|---|---|---|
float | 浮動方向 | left, right, none |
clear | 清除浮動 | left, right, both, none |
| 屬性 | 功能 | 值 |
|---|---|---|
z-index | 堆疊層級 | 整數(可負),數值大者在上層 |
visibility | 可見性 | visible, hidden, collapse (表格), inherit |
margin, padding, border, font, background, list-style)減少代碼量。line-height 建議使用無單位數值(倍數),利於繼承縮放。box-sizing: border-box 全域重置,統一盒模型計算。visibility: hidden 隱藏互動元素,改用 display: none 或 opacity: 0 配合 pointer-events: none。