【问题标题】:Conditional comments for CSS in IE9IE9 中 CSS 的条件注释
【发布时间】:2014-02-03 09:33:47
【问题描述】:

我想为 IE9 添加一个特定的样式表,它用不同的边距值覆盖 img.icon css 类。所以我在头部添加了以下内容。但是当页面加载时,它会在浏览器中显示为文本。

 <!--[if IE 9]>
    img.icon {
        float: right;
        margin: 4px -31px;
    }
    <![endif]-->

【问题讨论】:

    标签: javascript css internet-explorer-9


    【解决方案1】:

    您缺少&lt;style&gt; 标签

    <!--[if IE 9]>
    <style>
        img.icon {
            float: right;
            margin: 4px -31px;
        }
    </style>
    <![endif]-->
    

    【讨论】:

      【解决方案2】:
       <!--[if IE9]>
      <style>
          img.icon {
              float: right;
              margin: 4px -31px;
          }
      </style>
          <![endif]-->
      

      它认为

      【讨论】:

        【解决方案3】:

        您忘记了样式标签。

        <!--[if IE 9]>
        <style>
            img.icon {
                float: right;
                margin: 4px -31px;
            }
        </style>
        <![endif]-->
        

        此外,您可能会发现在条件 cmets 中加载外部样式表更容易:

        <!--[if IE 9]>
        <link rel="stylesheet" href="css/ie9.css">
        <![endif]-->
        

        【讨论】:

          猜你喜欢
          • 2011-11-29
          • 2011-03-01
          • 2011-07-26
          • 2012-06-15
          • 1970-01-01
          • 2012-04-10
          • 2014-05-03
          • 2012-05-07
          • 2017-01-21
          相关资源
          最近更新 更多