Three Forms of CSS Hack: Internal CSS Hack, selector Hack, and CSS condition annotation.
1. Internal hack:
IE6 special hack underline "_", IE6, 7 can recognize "*", "* +", "+", IE8, 9 support "\ 0", "\ 9 ", opera supports "\ 9 ".
|
IE6 |
IE7 |
IE8 |
IE9 |
Chrome |
Firefox |
Safari |
Opera |
_ |
√ |
× |
× |
× |
× |
× |
× |
× |
+ |
√ |
√ |
× |
× |
× |
× |
× |
× |
* |
√ |
√ |
× |
× |
× |
× |
× |
× |
* + |
√ |
√ |
× |
× |
× |
× |
× |
× |
\ 0 |
× |
× |
√ |
√ |
× |
× |
× |
× |
\ 9 |
× |
× |
√ |
√ |
× |
× |
× |
√ |
CSS hack TestView Code
2. selector hack:
CSS hack selector TestView Code
3.
The above are several commonly used syntax for judging the IE browser version. Next we will introduce the less-used logical judgment parameters: lte, lt, gte, gt and!
The detailed explanations are as follows:
! : Not equal
<! -- [If gt IE 7]>/if the IE version is later than 7/
<! -- [If lte IE 6]>/if the IE version is less than or equal to 6/
<! -- [If! IE]>/If the browser is not IE/
......
I believe that everyone understands the usage of the conditional annotation. OK. Let's take an example:
<! -- First use the css.css style sheet -->
<Link rel = "stylesheet" type = "text/css" href = "css.css"/>
<! -- [If! IE]>
<! -- Use the 1.css style sheet for non-ie-based access -->
<Link rel = "stylesheet" type = "text/css" href = "1.css"/>
<! [Endif] -->
<! -- [If lt IE 6]>
<! -- If the IE browser is less than 6, use the 2.css style sheet -->
<Link rel = "stylesheet" type = "text/css" href = "2.css"/>
<! [Endif] -->