隨專案規模增長,混亂的命名會讓維護陷入地獄。本文提供一套實戰驗證的命名規範,涵蓋字元規則、結構化公式、常用縮寫與實例。
.btn-submit),而非樣式(.red-button),樣式變更時命名仍具意義。[模組前綴|類型|功能]_[名稱]_[狀態|位置]
mkt、usr)login、search)單詞數控制在 2-3 個,保持簡潔。
| 全寫 | 縮寫 |
|---|---|
| setting | set |
| success | suc |
| hint/tip | hint |
| operation | op |
| password | pw |
| menu | menu |
| button | btn |
| text | txt |
| color | c |
| background | bg |
| border | bor |
| center | ctr |
| icon | ico |
| popup | pop |
.input-txt.input-pw.input-pw-login.hint-suc-blogset.pop-set-photo.hint-bg.c-txt.c-txt-p嚴謹的命名規範是 CSS 架構長期健康的基石,值得從專案伊始就投入建立。