IE 與 Firefox 在 CSS 解析上存在顯著差異,整理 11 大高頻兼容問題及解決方案,並補充 5 條實戰注意事項。
text-align:center,子層設 margin:auto。margin:auto 才能居中。!important 區分寫法:width:200px!important; width:220px;(IE6 讀後者)。color:red!important; color:blue;(順序不可顛倒)。vertical-align:middle 僅對行內/表格單元格有效。單行文字可用 line-height=height,多行需 Flex/Grid/Table-cell。cursor:pointer 標準寫法,雙瀏覽器支援;cursor:hand 僅 IE 支援。display:block; float:left 並排且加邊框背景;建議固定 height 避免底邊抖動。div{margin:30px!important; margin:28px;}(FF 取 30px,IE6 取 28px)。width:300px!important; width/**/:340px;(IE5 讀 340px,IE6/FF 讀 300px)。ul{margin:0;padding:0;} 統一基線。<div class="clear"></div>,.clear{clear:both;}。外層加 overflow:hidden; zoom:1; 觸發 BFC/hasLayout,高度自適應。margin 會加倍。修復:display:inline;(不影響塊級特性)。overflow:hidden。overflow:hidden; zoom:1; 修復 IE 高度塌陷。.tabd1{ background:url(...) !important; background:url(...); },重要聲明在前。新專案採用 Normalize.css/Reset.css + Autoprefixer + 現代佈局,避免手寫 Hack。舊專案維護時,條件註釋載入 IE 專用樣式表最清晰。