ie条件html语句

ie条件html语句,html,css,Html,Css,我在这里使用条件语句添加浏览器css样式 <!DOCTYPE html> <!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]--> <!--[if IE 7]> <html class="lt-ie9 lt-ie8"> <![endif]--> <!--[if IE 8]> <

我在这里使用条件语句添加浏览器css样式

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

如果我在模拟器中测试此条件语句似乎不起作用,则html标记没有“lt-ie9”类

如果我在像browserstack这样的产品中进行测试,条件语句似乎可以工作,我可以看到与class.lt-ie9一起显示的文本

条件html标记正确吗?我不应该相信仿真者吗

    <!DOCTYPE html>
    <!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
    <!--[if IE 7]>    <html class="lt-ie9 lt-ie8"> <![endif]-->
    <!--[if IE 8]>    <html class="lt-ie9"> <![endif]-->
    <!--[if gt IE 8]><!--> <html class=""> <!--<![endif]-->
        <head>  
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />

            <!--jQuery-->
            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>

            <!--css-->
            <style type="text/css">

          .test{
            color: red;
            display: none;
            font-size: 2em;
          }

          .lt-ie9 .test{
            display: block;
          }

            </style>


            <!--[if lt IE 9]>
                <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
            <![endif]-->

            <title>Title of the document</title>
        </head>

    <body>

      <div class="test">IE8</div>

    </body>

    </html>

.测试{
颜色:红色;
显示:无;
字号:2em;
}
.lt-ie9.测试{
显示:块;
}
文件标题
IE8

如果不知道有问题的模拟器,我们就无法知道。调试过程中最好的做法是将代码复制到主体中,并用可见的内容替换html标记:

<!--[if lt IE 7]> IE, Less than 7<![endif]-->
<!--[if IE 7]>    IE 7 <![endif]-->
<!--[if IE 8]>    IE 8 <![endif]-->
<!--[if gt IE 8]><!--> IE 9+ or not-IE <!--<![endif]-->

IE 9+还是不IE