1、IE条件注释法
<!--[if IE]>
<linke type =”text/css” href=”test.css” rel=”stylesheet” />
<![endif]-->
<!--[if IE 6]>
<linke type =”text/css” href=”test.css” rel=”stylesheet” />
<![endif]-->
<!--[if ! IE 6]>
<linke type =”text/css” href=”test.css” rel=”stylesheet” />
<![endif]-->
<!--[if IE 6]>
<style typej=”text/css”>
.test{}
</style>
<![endif]-->
<!--[if IE 6]>
<script type=”text/Javascript”></script>
<![endif]-->
2、选择符前缀法
<style type=”text/css”>
.test{width:80px;}/*IE 6,7,8 */
*html .test{width:60px;}/*only for IE 6*/注意一定是*html打头,其它如*body不能作区分hacker
*+html .test{width:70px;}/*only for IE 7 IE 8 beta*//注意一定是*html打头,其它如*body不能作区分hacker
</style>
注意:IE 9,10不识别;不能用于内联样式;
注意:*+html 对IE7的HACK 必须保证HTML顶部有如下声明:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” ”http://www.w3.org/TR/html4/loose.dtd”
以上是 网上说的,经本人测试html5标准也可以*+html
3、样式属性前缀法
<style type=”text/css>
.test{
width:80px;
*width:70px;/*for IE6,7;还可以是#或者+*/
_width:60px;/*for IE 6*/
color:red\0;/*IE 8 only*/
Color:red\9;/*ALL IE*/
[;background-color:green;]/*safari, chrome*/
}
区别 FF, IE7, IE6:
background:orange;*background:green !important;*background:blue;
注:IE都能识别*;标准浏览器(如FF)不能识别*;
IE6能识别*,但不能识别 !important,
IE7能识别*,也能识别!important;
FF不能识别*,但能识别!important;
| IE6 | IE7 | FF |
* | √ | √ | × |
!important | × | √ | √ |