1.IE条件注释法
只在IE下生效
<!--[if IE]>
<link type="text/css" href="..." rel="stylesheet" />
<![endif]-->
只在IE6下生效
<!--[if IE6]>
<link type="text/css" href="..." rel="stylesheet" />
<![endif]-->
只在IE6以上版本生效
<!--[if gt IE6]>
<link type="text/css" href="..." rel="stylesheet" />
<![endif]-->
只在IE7上不生效
<!--[if ! IE7]>
<link type="text/css" href="..." rel="stylesheet" />
<![endif]-->
关键字lte表示"小于等于",lt表示"小于",gte表示"大于等于",gt表示"大于",!表示"不等于".
2.选择符前缀法
<style type="text/css">
.test{width:80px;}/*IE6,IE7,IE8*/
*html .test{width:60px;}/*only for IE6*/
*+html .test{width:70px;}/*only for IE7*/
</style>
这个方法不能用在内联样式中,因为内联样式根本就没有用到选择符.
3.样式属性前缀法
<style type="text/css">
.test{width:80px;*width:70px;_width:60px}
</style>
"_"只在IE6下生效,"*"在IE6和IE7下生效.