IE浏览器Hack一般又分为三种,条件Hack、属性级Hack、选择符Hack(详细参考CSS文档:css文档)。例如:
1、条件Hack
<!--[if IE]>
<style>
.test{color:red;}
</style>
<![endif]-->
<!--[if IE 8]>
<html class="ie8 lte_ie9" lang="en">
<![endif]-->
<!--[if lte IE 9]>
<script src="libs/bootstrap/js/html5shiv.min.js"></script>
<script src="libs/bootstrap/js/respond.min.js"></script>
<html class="lte_ie9" lang="en">
<![endif]-->
<!--[if !IE]><!-->
<script>
// 针对IE10
if (/*@cc_on!@*/false) {
document.documentElement.className += ' ie' + document.documentMode;
}
// 针对IE11及非IE浏览器,
if (/*@cc_on!@*/true) {
document.documentElement.className += ' ie' + document.documentMode;
}
</script>
<!--<![endif]-->
2、属性Hack
.test{
color:#090\9; /* For IE8+ */
*color:#f00; /* For IE7 and earlier */
_color:#ff0; /* For IE6 and earlier */
}
3、选择符Hack
* html .test{color:#090;} /* For IE6 and earlier */
* + html .test{color:#ff0;} /* For IE7 */