標籤:style blog http color io os ar 使用 for
一、CSS HACK
1、在同一個CSS樣式表中,使用 !important 來定義不同的值以適應Firefox和IE,例如:
#box { color:red !important; color:blue; }
(注意這裡IE6是無法識別 !important 這個標記的,但它會識別padding: 20px,所以要在後面加上padding: 10px用來覆蓋padding: 20px)
2、為特定瀏覽器設定特定的樣式
height:20px; /*For all 包括Firefox */*height:25px; /*For IE7 & IE6*/_height:20px; /*For IE6*/*+height:20px /* IE7 */
#someNode{ position: fixed; /*給Firefox以及其他瀏覽器看 */ #position: fixed; /*給IE7看 */ _position: fixed; /*第三排給IE6以及更老的版本看*/}
*+html 與 *html 是IE特有的標籤, firefox 暫不支援。
*+html 對IE7的HACK 必須保證HTML頂部有如下聲明:
XML/HTML代碼
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
二、float 閉合
關於 clear float 的原理可參見 [How To Clear Floats Without Structural Markup]
將以下代碼加入Global CSS 中,給需要閉合的div加上 class="clearfix" 即可。
/* Clear Fix */.clearfix:after { content:"."; display:block; height:0; clear:both; visibility:hidden; } .clearfix { display:inline-block; }/* Hide from IE Mac /*/ .clearfix { display:block; } /* End hide from IE Mac */ /* end of clearfix */
待補充......
多瀏覽器CSS樣式解決方案