IE和FF下CSS樣式的區別

來源:互聯網
上載者:User
FF對盒模型的解釋也不一樣,代碼說明:#test { width: 650px !important;width: 648px;padding-left:2px;background:#fff; }
test 顯示的寬頻是 650px
IE Box的總寬度是: width+padding+border+margin寬度總和
FF Box的總寬度就是 width的寬度,padding+border+margin的寬度在含在width內。
如果有BOX{WIDTH:"300"; PADDING:"5PX";}
則BOX在IE的寬度應該為:310
而在FF的寬度則是300
所以在BOX有填充的情況下應該這樣使用
BOX{WIDTH:"290"!IMPORTANT; WIDTH: "300";}
這樣子才能確保BOX的寬度始終在300px,而不會出現被撐開的現象
而在FF裡面則不會造成浮動層填不滿的情況
五:ul 標籤在 Mozilla 中有 padding 值的,而在 IE 中只有 margin 有值。
設定ul{margin:0;padding:0}
針對firefox ie6 ie7的css樣式
現在大部分都是用!important來hack,對於ie6和firefox測試可以正常顯示,
但是ie7對!important可以正確解釋,會導致頁面沒按要求顯示。找到一個針
對IE7不錯的hack方式就是使用“*+html”,現在用IE7瀏覽一下,應該沒有問題了。
現在寫一個CSS可以這樣:
#1 { color: #333; } /* Moz */
* html #1 { color: #666; } /* IE6 */
*+html #1 { color: #999; } /* IE7 */
那麼在firefox下字型顏色顯示為#333,IE6下字型顏色顯示為#666,IE7下字型顏色顯示為#999
可以用”+”來實現只有IE識別的CSS Hack
可能有朋友想到用”_” Hack,但它們是由區別的,因為IE7中是不識別“_”的。所以用+
測試結果:
IE5.5,IE6 ,IE7瀏覽器都能識別;
FF2.0,Opera 9,Safari 2瀏覽器不識別
 
相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.