* { margin:0; padding:0; }?form、table、input 等元素原生間距,導致表單對齊、表格邊框崩壞,需大量補回樣式。blockquote、ul)預設間距有語意價值,不應盲目歸零。/ * 1. 清除內外邊距 * /
body, h1, h2, h3, h4, h5, h6, hr, p,
blockquote, /* 結構元素 */
dl, dt, dd, ul, ol, li, /* 列表元素 */
pre, /* 文本格式元素 */
form, fieldset, legend, button, input, textarea, /* 表單元素 */
th, td, /* 表格元素 */
img { /* 圖片元素 */
margin: 0;
padding: 0;
border: 0; /* 圖片預設無邊框 */
}
/ * 2. 設置預設字體 * /
body, button, input, select, textarea {
font: 12px/1.5 "Microsoft YaHei", Tahoma, Arial, Helvetica, sans-serif;
}
h1, h2, h3, h4, h5, h6 { font-size: 100%; font-weight: normal; }
em, i { font-style: normal; }
/ * 3. 重置列表元素 * /
ul, ol { list-style: none; }
/ * 4. 重置超鏈接 * /
a { text-decoration: none; color: #333; }
a:hover { text-decoration: underline; color: #f40; }
/ * 5. 重置圖片 * /
img { border: 0; vertical-align: middle; } /* 修正底部間隙 */
/ * 6. 重置表格 * /
table { border-collapse: collapse; border-spacing: 0; }
npm install normalize.css → @import 'normalize.css';box-sizing: border-box 全域繼承:*, *::before, *::after { box-sizing: border-box; }postcss-normalize 根據 browserslist 自動注入所需 normalize 規則。CSS Reset 核心在於「精準、克制、標準化」。拒絕暴力全域歸零,採用元素清單重置或 Normalize.css,配合 box-sizing: border-box,建立穩健、可預測的樣式基線。