頁面重構這份工作,從局部細節到頁面整合,再到整體系統結構,每個環節都有不同的處理技巧與思考方式。以下把實戰中容易犯錯、也最該記住的重點整理成清單。
有定義文檔類型時:
{font-size:3px; margin:5px;}(值為 0 時可省略單位)。未定義文檔類型時:
margin:5; 等同 margin:5px;(值為 0 時可省略)。display:inline 解決,比使用 _ hack 更合理。.clear{clear:both;font-size:1px;width:1px;visibility:hidden;margin-top:0px!important;*margin-top:-1px;line-height:0}<div class="clear"></div>;IE 用 height:1%,Firefox 則用:after 擬似元素寫入 content:"."; display:block; clear:both; height:0; visibility:hidden;。重點在擴展性與自適應。
position:relative 搭配 position:absolute,以圓角圖片做絕對定位;再配合 border:1px solid #ccc 與負值 margin(如 margin:-1px)修邊。div{border:0 solid #A5DA94; font-size:0; height:1px; margin:0 1px; overflow:hidden;},透過調整 margin 與 border-width 做出漸層效果。tr:hover td 在 IE6 無效,因為它只支援 a 上的 :hover 偽類)。font-family: Arial, Helvetica, sans-serif;,否則特殊符號會變形。_property:value 適用 IE6 及以下。*property:value 適用所有 IE。*+html div 適用 IE7、IE5。{text-indent:-9999px;}(值不必太大,過大會拖慢渲染)。display:none 整體隱藏,不影響其他樣式。overflow:hidden 隱藏溢出部分。{font-size:0;}。text-align:center;,元素設 width:*px; margin:0 auto;。_height:*px;,IE6 內容超出時仍會自動撐高。