把每天會用到的屬性整理成一份清單,寫樣式時翻一下就能對齊語法。
background: #00ffee; /* 背景色 */ background-image: url(*.jpg); /* 背景圖 */ background-repeat: repeat-x; /* 水平重複 */ background-attachment: fixed; /* 不隨內容滾動 */
text-indent: 5em; /* 首行縮排 */ text-transform: uppercase; /* 大小寫轉換:uppercase / lowercase / capitalize */ text-decoration: none; /* underline / overline / line-through / blink */ white-space: normal; /* pre 可保留空白與換行 */ color: #eeffee; line-height: 30px;
font-family: Georgia; /* 字型系列 */ font-style: normal; /* italic 斜體、oblique 傾斜 */ font-weight: normal; /* bold 或 100~900 數值 */ font-size: 16px; font-variant: small-caps; /* 小型大寫字母 */
有序清單可用 decimal、decimal-leading-zero、lower-roman、upper-roman、lower-alpha、upper-alpha;無序清單則有 disc、circle、square。
border-collapse: collapse; /* 合併相鄰框線 */ border: 1px solid black; width: 100%; height: 50px; text-align: right; /* 水平對齊 */ vertical-align: bottom; /* 垂直對齊 */ padding: 15px; color: white; background-color: green;
outline: #00ff00 dotted thick; /* 輪廓:顏色 / 樣式 / 寬度 */ border: blue solid thin; /* 邊框:顏色 / 樣式 / 寬度 */
兩者常被搞混:border 會佔據版面並參與盒模型計算,outline 則繪製在元素之外、不影響布局,因此很適合拿來做焦點提示樣式。