【问题标题】:Why are my IE conditional statements not working?为什么我的 IE 条件语句不起作用?
【发布时间】:2013-06-07 03:31:19
【问题描述】:

我有以下几点:

  <!--[if IE]>
    <style>
      iframe {
        margin-top: 0 !important;
        display: none;
      }
      .c-position {
        margin-top: 20px !important;
      }
      br {
        display: none;
      }
    </style>
  <![endif]-->

但是当我在 IE10 中看到我的 site 时,没有应用 IE 条件语句中的 CSS(例如 iframe 应该消失)。

我什至把这个绑起来了:

  <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">

所以 IE10 可以识别条件语句。

为什么我做错了?

【问题讨论】:

  • 这里真正的问题是为什么你需要区别对待 IE10。您的 iframe 的内容是否像在例如铬?

标签: css internet-explorer internet-explorer-10 conditional-comments


【解决方案1】:

也许你可以像这样尝试一些适用于 ie10 的 jQuery:

if ($.browser.msie && $.browser.version == 10) {
  $("html").addClass("ie10");
}

但它肯定不是条件 cmets 的替代品!

【讨论】:

【解决方案2】:

IE10 不支持条件 cmets。

Source quote:

已在 Internet Explorer 中删除对条件 cmets 的支持 10 种标准和怪癖模式,用于提高互操作性和 符合 HTML5。这意味着条件注释现在是 被视为常规 cmets,就像在其他浏览器中一样。

【讨论】:

    猜你喜欢
    • 2011-12-20
    • 2010-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-21
    • 1970-01-01
    • 1970-01-01
    • 2011-07-16
    相关资源
    最近更新 更多