css hack

   CSS hack用来解决有些css属性在不同浏览器中显示的效果不一样的问题。CSS hack的目的就是使你的CSS代码兼容不同的浏览器。

   css hack指各版本及各品牌浏览器之间对CSS解释后出现网页内容的误差的处理.简单的说css hack就是在CSS样式中加入一些特殊符号,让浏览器识别不同的符号,从而达到css样式在浏览器中的兼容问题。

   IE浏览器Hack一般又分为三种,条件Hack、属性级Hack、选择符Hack(详细参考CSS文档:css文档)。例如:

// 1、条件Hack

<!--[if IE]>

<style>

.test{color:red;}

</style>

<![endif]-->

// 2、属性Hack

.test{

color:#0909; /* 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 */

http://www.kwstu.com/Admin/ViewArticle/201409011604277330

宝剑锋从磨砺出,梅花香自苦寒来。
原文地址:https://www.cnblogs.com/haimengqingyuan/p/5340376.html