从多个浏览器隐藏HTML部分条件注释 [英] Hiding HTML portion from several browsers Conditional Comments

查看:143
本文介绍了从多个浏览器隐藏HTML部分条件注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要的是,我想要这部分html代码隐藏从IE6和IE7,但不是firefox,歌剧或IE8,但条件注释在这个部分上不能正常工作....我使用单独的CSS与条件评论在头部分但是对于歌剧的条件注释不工作,有时Firefox显示奇怪的行为

What i want is that i want this portion of html code to be hidden from IE6 and IE7 but not firefox, opera or IE8 but conditional comments not working properly on this portion....I am using separate CSS with conditional comments in the head section But conditional comments for opera are not working and also sometimes Firefox shows strange behaviour

<!--[if gte IE 8]>
    <[if Gecko]>


 <div class="anythingSlider">

      <div class="wrapper">
        <ul>
           <li>
                <img src="gallery/1.jpg" alt="" />
           </li>
            <li>
                <img src="gallery/2.jpg" alt="" />
           </li>

        </ul>
     </div>
 </div>

     <[endif]>
<[endif]––>


推荐答案

没有这样的东西:

<[if Gecko]>

条件注释仅适用于IE,因此您只能区分IE5,IE6,IE7,IE8 [所有其他浏览器]。 (幸运的是,通常只有IE6和IE7需要嗅探!)

Conditional comments only work for IE, so you can only distinguish between IE5, IE6, IE7, IE8 and [all other browsers]. (Luckily, it's usually only IE6 and maybe IE7 you need to sniff for!)


我希望这部分html代码被隐藏IE6和IE7

i want this portion of html code to be hidden from IE6 and IE7

确定,显示条件注释的内容不仅仅在测试条件,而且在[所有其他浏览器] ,您需要低级发布的条件评论

OK, to show the contents of a conditional comment not just on the tested condition but also on [all other browsers], you need a downlevel-revealed conditional comment:

<!--[if gte IE 8]><!-->
    <div class="anythingSlider">
        ...
    </div>
<!--<![endif]-->

(注意这不是官方MS语法的一个downlevel-显示CC,无效的HTML。)

(Note this is not quite the official MS syntax for a downlevel-revealed CC, because that would be invalid HTML.)

这篇关于从多个浏览器隐藏HTML部分条件注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆