IE9的css hack

來源:互聯網
上載者:User

div {

background-color:red\0;  /* ie 8/9*/

background-color:blue\9\0;  /* ie 9*/

*background-color:green;  /* ie 7*/

_background-color:gray;  /* ie 6*/

}

注意寫csshack的順序,其中:

1.background-color:red\0;IE8和IE9都支援;
2.background-color:blue\9\0; 僅IE9支援;

(1)區別FF(IE8)與IE6 IE7

backgorund:orange; FF和IE8背景色將為橘黃色

*backgorund:red;   IE6和IE7背景色將為紅色

(2)區別FF(IE8)與IE6與IE7

background:orange;   FF和IE8背景色將為橘黃色

*background:red !important;  IE7背景色將為紅色

*background:blue;     IE6背景色將為藍色

(3)區別FF(IE8)與IE6與IE7

background:orange;        FF和IE8背景色將為橘黃色

*background:red;          IE7背景色將為紅色

_background:blue;         IE6背景色將為藍色

(4)區別FF與IE6 IE7 IE8 IE9

color:gray;       FF等非IE瀏覽器字型色將為灰色

color:red\9;     IE8 IE9字型色將為紅色

*color:green;     IE7字型色將為綠色

_color:blue;     IE6字型色將為藍色

提示:CSS HACK書寫順序:先寫FF等非IE瀏覽器所需樣式,其次寫IE8/9所需樣式,接著是IE7的,再接著才是IE6的!

總結:實際運用中我感覺比較少用到!important ,只要你記住”*”和”_”我想就足夠區別於FF(IE8)與IE6與IE7了.

相關文章

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.