字體屬性
| 屬性 | 說明 | 常用值 |
font-family | 字體清單,依序尋找 | "Microsoft JhengHei", sans-serif |
font-style | 字體風格 | normal | italic | oblique |
font-variant | 小型大寫字母 | normal | small-caps |
font-weight | 粗細 | normal(400) | bold(700) | 100-900 |
font-size | 字體大小 | 16px, 1rem, 1.2em, 120% |
font | 綜合簡寫(順序:style variant weight size/line-height family) | italic bold 16px/1.5 "Microsoft JhengHei" |
文本屬性
| 屬性 | 說明 | 常用值 |
text-decoration | 修飾線 | none | underline | overline | line-through |
text-align | 水平對齊 | left | right | center | justify |
text-indent | 首行縮排 | 2em, 24px |
letter-spacing | 字元間距 | 0.1em, 2px(可負值) |
word-spacing | 單詞間距 | 0.2em |
white-space | 空白處理 | nowrap | pre | pre-wrap |
text-transform | 大小寫轉換 | uppercase | lowercase | capitalize |
顏色屬性
color: #333; / rgb(51,51,51) / hsl(0,0%,20%) — 參考「顏色表示法」五種格式。
背景屬性
| 屬性 | 說明 | 常用值 |
background-color | 背景色 | 同顏色格式 |
background-image | 背景圖 | url(bg.png) |
background-repeat | 平鋪方式 | repeat | repeat-x | repeat-y | no-repeat |
background-attachment | 固定/捲動 | scroll | fixed | local |
background-position | 定位 | center top, 50% 50%, 10px 20px |
background | 綜合簡寫 | #fff url(bg.png) no-repeat center / cover |
邊距屬性
| 屬性 | 說明 | 簡寫順序 |
margin | 外距 | 上 右 下左(順時針)
margin: 10px 20px 30px 40px; |
padding | 內距 | 同上 |
border | 邊框 | border: 1px solid #ccc;(寬 樣式 色) |
簡寫規則:1 值=四邊;2 值=上下/左右;3 值=上/左右/下;4 值=上右下左。