zoukankan      html  css  js  c++  java
  • ie条件注释

    1 <!--[if lt IE 7]>      <html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
    2 <!--[if IE 7]>         <html class="lt-ie9 lt-ie8">        <![endif]-->
    3 <!--[if IE 8]>         <html class="lt-ie9">               <![endif]-->
    4 <!--[if gt IE 8]><!--> <html>                              <!--<![endif]-->

    能够正确的理解上面这段的执行过程的话,对ie条件注释的使用应该是掌握了、

    第1行:
    浏览器为ie6及ie5判断为真,所以解析为<html class="lt-ie9 lt-ie8 lt-ie7">
    浏览器为ie7--ie9判断为假,解析为空。
    ie10及以上和非ie浏览器作为注释忽略掉(因为他们都不支持条件注释)。

    第二行,第3行,
    解析过程类似于行1.

    第4行比较特殊:
    浏览器为ie5-ie9的话判断为假,解析为空。
    浏览器为ie9,判断为真,解析出<html>。
    浏览器为ie10及以上和非ie,<![if gt IE 8]> 以及 <![endif]>会被当做无法识别的标签,整条代码最终被解析为<html>。

    如果按下面这样写的话其实是错误的。
    <!--[if gt IE 8 | !IE]> <html> <![endif]-->
    ie9判断为真,解析出<html>。可是ie10及非ie浏览器会把它当做注释忽略,因此无法正确解析出<html>。

    总结:
    ie条件注释只能被ie浏览器解析,非ie浏览器当做注释处理、
    所以<!--[if !IE]>html<![endif]-->,实际上并无实际用途。并不能让非ie浏览器解析出html。
    如果想排除ie让其他浏览器正确解析的话,应该使用
    <!--[if !IE]><!--> <html>                              <!--<![endif]-->
    这种条件注释的类型被称作downlevel-hidden

    参考:http://www.veryhuo.com/a/view/50853.html
  • 相关阅读:
    static 和final
    Integer中getInteger(),valueof()
    Integer和String "+""=="方法的不同
    java中Integer常量池
    用jvm指令分析String 常量池
    多线程、线程安全
    String字符串缓冲区、StringBuffer
    TCP通信---文件上传案例、多线程文件上传
    网络通信协议、UDP通信、TCP通信
    Java线程-- 线程池
  • 原文地址:https://www.cnblogs.com/web-coding/p/4764133.html
Copyright © 2011-2022 走看看