/* ✅ 推薦:多行展開,屬性分組,巢狀映射 DOM */
.card {
/* Layout */
display: flex;
flex-direction: column;
gap: 16px;
/* Box Model */
width: 100%;
max-width: 400px;
padding: 24px;
margin: 0 auto;
/* Visual */
background-color: #fff;
border: 1px solid var(--border-color);
border-radius: 12px;
box-shadow: var(--shadow-md);
/* Typography */
font-family: var(--font-family-base);
color: var(--text-primary);
line-height: 1.6;
}
/* 子元素巢狀縮進,映射 DOM 結構 */
.card__header {
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid var(--border-color);
padding-bottom: 16px;
margin-bottom: 8px;
}
.card__title {
font-size: 1.25rem;
font-weight: 600;
color: var(--text-heading);
}
/* ❌ 不推薦:單行壓縮,難讀、難維護、Diff 雜訊大 */
.card{display:flex;flex-direction:column;gap:16px;width:100%;max-width:400px;padding:24px;margin:0 auto;background-color:#fff;border:1px solid var(--border-color);border-radius:12px;box-shadow:var(--shadow-md);font-family:var(--font-family-base);color:var(--text-primary);line-height:1.6;}
.u-hidden { display: none !important; }@keyframes spin { to { transform: rotate(360deg); } }1. Positioning : position, top, right, bottom, left, z-index, display, float, clear
2. Box Model : width, height, max/min-width/height, margin, padding, border, box-sizing
3. Flex/Grid : flex/grid 相關屬性
4. Visual : background, box-shadow, opacity, transform, filter, clip-path
5. Typography : font, color, text-align, line-height, letter-spacing, white-space
6. Animation : animation, transition
7. Misc : cursor, pointer-events, user-select, will-change
{
"singleQuote": true,
"tabWidth": 2,
"printWidth": 120,
"cssSingleQuote": true,
"endOfLine": "lf"
}
{
"extends": ["stylelint-config-standard", "stylelint-config-recess-order"],
"rules": {
"block-opening-brace-space-before": "always",
"declaration-colon-space-after": "always",
"declaration-block-trailing-semicolon": "always",
"declaration-block-single-line-max-declarations": 1,
"selector-class-pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*(__[a-z0-9]+(-[a-z0-9]+)*)?(--[a-z0-9]+(-[a-z0-9]+)*)?$"
}
}
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"css.validate": false, /* 關閉內建驗證,交給 Stylelint */
"stylelint.enable": true
}
CSS 可讀性不是主觀審美,是**協作效率的量化指標**。多行展開、語義分組、巢狀映射、單行例外、自動化強制,五位一體構建「零格式爭議、零認知負擔、零合併衝突」的樣式代碼庫。投資配置工具鏈,收獲長期複利。