width 包含 padding + border。width 僅內容區,padding/border 向外擴展。div.content {
width: 400px; /* 所有瀏覽器讀到 */
voice-family: "\"}\""; /* IE5.x 忽略後續 */
voice-family: inherit;
width: 300px; /* IE6+、現代瀏覽器覆蓋 */
}
html > body .content { /* CSS2 子選取器,IE6- 忽略 */
width: 300px;
}
div.content {
width: 300px !important; /* 標準瀏覽器採用 */
width /**/: 400px; /* IE5.x 讀到覆蓋;IE6+ 忽略 */
}
html > body .content {
width: 300px;
}
/**/ 註解讓 IE5.x 解析出 width:400px,IE6+ 視為無效而忽略。
<!DOCTYPE html>)→ 標準模式 → 統一渲染行為,Hack 才能生效。<!DOCTYPE html> 開頭。* html 或 _ Hack,並加註說明。
4. 放棄 IE5.x 支援(市佔率極微),簡化 Hack 鏈。