HTML中的Hack条件注释语句

时间:2023-03-09 16:42:02
HTML中的Hack条件注释语句
IE 条件注释判断语句是 IE 特有的功能,通过 HTML 注释中的条件语句能让不同的 IE 版本识别注释中的内容

自IE10起,标准模式不再支持条件注释
条件注释语句中可以是HTML、CSS也可以是JavaScript,空格和大写不要写错
1.只能被 IE 识别
  <!--[if IE]>
   只能被 IE 识别;
  <![endif]--> 2.IE6
  <!--[if IE 6]>
   这是ie6
  <![endif]--> 3.IE7
  <!--[if IE 7]>
  这是ie7
  <![endif]-->
4.IE8
  <!--[if IE 8]>
  这是ie8
  <![endif]-->
5.IE9
  <!--[if IE 9]>
    这是ie9
  <![endif]-->
6.高于IE6
  <!--[if gt IE 6]>
  这是大于ie6
  <![endif]-->
也可以有下面这几种写法
<!--
gt(reater than) 大于
gte(greater than or equal)大于等于
lt(less than) 小于
lte(less than or equal) 小于等于
! 非
-->