相信大家都知道IE有专门的注释条件判断来引入一些css、js、html代码,但是语法有点拗口,记不住,下面我来做一下笔记:
正常的html注释: <!--注释注释注释注释...--> 注释条件判断 IE7: <!--[if IE 7]> 引入的任何css、js、html <![endif]--> IE7及以上: <!--[if gte IE 7]> 引入的任何css、js、html <![endif]--> IE7及以下: <!--[if lte IE 7]> 引入的任何css、js、html <![endif]--> IE7以上(不含IE7): <!--[if gt IE 7]> 引入的任何css、js、html <![endif]--> IE7以下(不含IE7): <!--[if lt IE 7]> 引入的任何css、js、html <![endif]--> IE7或IE8: <!--[if IE 7|IE 8]> 引入的任何css、js、html <![endif]--> 非IE7或IE8: <!--[if lt IE 7|gt IE 8]> 引入的任何css、js、html <![endif]--> 或者 <!--[if !(IE 7|IE 8)]> 引入的任何css、js、html <![endif]-->
非IE的写法比较特殊:
<!--[if !IE]>--> 任何css、js、html <!--<![endif]-->
IE判断的写法只兼容到IE9,到IE10已经是只显示非IE注释的内容了,所以我们现在习惯叫的IE浏览器其实多是指IE9及以下