CSS hack 汇总

1, IE条件注释法,微软官方推荐的hack方式。

<!--[if gte IE 6]> IE6以及IE6以上版本可识别 <![endif]-->
<!--[if IE 7]> 仅IE7可识别 <![endif]-->
<!--[if lt IE 7]> IE7以及IE7以下版本可识别 <![endif]-->
<!--[if gte IE 7]> IE7以及IE7以上版本可识别 <![endif]-->
只在IE下生效
<!--[if IE]>
这段文字只在IE浏览器上显示
<![endif]-->
只在IE6下生效
<!--[if IE 6]>
这段文字只在IE6浏览器上显示
<![endif]-->
只在IE6以上版本生效
<!--[if gt IE 6]>
这段文字只在IE6以上版本IE浏览器上显示
<![endif]-->
只在IE7上不生效
<!--[if ! IE 7]>
这段文字在非IE7浏览器上显示
<![endif]-->
非IE浏览器生效
<!--[if !IE]><!-->
这段文字只在非IE浏览器上显示
<!--<![endif]-->

读此文css hack 汇总,突然想起来,好久没有写css了,都快把hack的方式給忘了,重新回顾一下:

_  只对ie6生效

*  只对ie6, ie7生效

  • “9″  只在IE6/IE7/IE8/IE9/IE10下生效
  • “”  只在 IE8/IE9/IE10下生效
  • “9”只在IE9/IE10下生效
  • 目前如果需要只针对ie8的hack,可先使用在IE8/IE9/IE10生效的“”,再用仅在IE9/IE10生效的“9”hack覆盖之前的样式。

selector{
  color:#F000;  /* only for IE8&IE9&IE10 */
  color:#00090; /* only for IE9&IE10 */
}

---------------------------------------------------------------------

CSS Hack

  1. _          IE6
  2. *          IE6/7
  3. !important IE7/Firefox
  4. *+         IE7
  5. 9         IE6/7/8
  6.          IE8
  7. 条件hack
      <!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]--> IE7以下版本
      <!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"><![endif]--> IE7
      <!--[if IE 8]> <html class="no-js lt-ie9"><![endif]--> IE8
      <!--[if gt IE 8]><!--><html class="no-js"><!--<![endif]--> IE8以上

<转载自:http://blog.csdn.net/liuxiaoyue909/article/details/8471422 & http://lfsp.btwlo.com/cssHack.html>

没有人告诉你,生活会是这样:你工作无趣,你袋里没钱,你的爱情总是昙花一现;妈妈警告过你,会有这样的日子但她没有告诉你,世界将让你屈服。但是,别怕,有我在你身边,谁让我们是friends呢……
原文地址:https://www.cnblogs.com/ChandlerVer5/p/css_hack.html