針對firefox ie6 ie7 ie8的css樣式hack

來源:互聯網
上載者:User

詳細出處參考:http://www.jb51.net/css/15987.html

今天做tab切換的時候,遇到問題,ie8,ie7,firefox對px高度的解析不統一,開始的時候打算
!important 解決之,後來發現ie7,ie8都支援這個了。根本無法判斷。於是在網上找到一篇文章。

 

針對firefox ie6 ie7 ie8的css樣式hack 以前我們大部分都是用!important來hack,對於ie6和firefox測試可以正常顯示,但是ie7以上對!important可以正確解釋,會導致頁面沒按要求顯示!搜尋了一下,找到了一個針對IE7、IE8不錯的hack方式,IE7使用*+html或*line-height: 23px

 

針對firefox ie6 ie7 ie8的css樣式hack
以前我們大部分都是用!important來hack,對於ie6和firefox測試可以正常顯示,但是ie7以上對!important可以正確解釋,會導致頁面沒按要求顯示!搜尋了一下,找到了一個針對IE7、IE8不錯的hack方式,IE7使用*+html或*line-height: 23px,IE8使用“\9”來區分,比如:line-height: 26px\9。

 

CSS可以參照如下定義,注意順序:
#menu { line-height: 23px; }/* firefox 瀏覽器實行這句定義 */
#menu { line-height: 26px\9; }/*ie6,ie7,ie8 這句定義主要尖對IE8來hack*/
#menu { *line-height: 23px; }/*ie6,ie7 這句定義主要尖對IE7來hack*/
#menu { _line-height: 23px; }/*ie6 瀏覽器優先實行這句定義*/ 或者寫成一句

#menu { line-height:23px; line-height: 26px\9; *line-height: 23px; _line-height:23px; } 或者

* html #menu { line-height: 23px; } /* IE6 瀏覽器實行這句定義 */
*+html #menu { line-height: 23px; }/* IE7 瀏覽器實行這句定義*/

詳細出處參考:http://www.jb51.net/css/15987.html

相關文章

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.