如何获得“IE 6条件注释”加工? [英] How do you get "IE 6 conditional comments" working?

查看:98
本文介绍了如何获得“IE 6条件注释”加工?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个标记工作正常:

i have this markup which works fine:

<div id="hd1" class="header headerNotIE6">

我现在试图放一个ie6特定的解决方法,所以我试图只有这个div如果浏览器不是IE 6.所以我想要这行,如果其IE7,8和Firefox和chrome。我试过这个,但它似乎不工作在Firefox或Chrome。

i am now trying to put a ie6 specific workaround so i am trying to only have this div if the browser is not IE 6. So i want this line to hit if its IE7, 8 and firefox and chrome. I tried this but it doesn't seem to work in Firefox or Chrome.

<!--[if !(IE 6)]>
    <div id="hd1" class="header headerNotIE6">
<![endif]-->

是否有任何如果除IE6以外的条件注释 p>

is there any "if everything but IE6" conditional comment that works in an html file ??

推荐答案

要使用 / p>

To target any IE except IE6, you use the ! operator:

<!--[if !IE 6]>
    <div id="hd1" class="header headerNotIE6">
<![endif]-->

要定位IE6之外的任何IE 以及所有其他浏览器需要特殊语法来突破条件注释,以便其他浏览器可以读取和解析HTML里面的HTML,而不是将整个块看作一个注释:

To target any IE except IE6 as well as all other browsers, you need special syntax to break out of the conditional comments so other browsers can read and parse the HTML inside, instead of seeing the entire block as one comment:

<!--[if !IE 6]><!-->
    <div id="hd1" class="header headerNotIE6">
<!--<![endif]-->

原始语法如 voyager的回答,称为 downlevel-revealed 语法,缺少额外的注释分隔符。但是,它是无效的HTML,因此为了保持文档的有效性,应该使用上述语法。

The original syntax as shown in voyager's answer, known as downlevel-revealed syntax, lacks the extra comment delimiters. However, it is invalid HTML, so to maintain document validity you should use the above syntax instead.

这篇关于如何获得“IE 6条件注释”加工?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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