【问题标题】:How can I load only a single specific style sheet when using Internet Explorer?使用 Internet Explorer 时,如何仅加载单个特定样式表?
【发布时间】:2011-08-24 19:49:11
【问题描述】:

如果 html 在 IE 中打开,我只想使用不同的样式表。但是,它似乎也从 style.css 中提取了一些元素属性。怎么会这样? [if gte IE 5] 不确保只使用 IEstyle.css 吗?解决此问题的最佳方法是什么?
谢谢。

<head>
    <title>!</title>

 <link rel="stylesheet" href="style.css" type="text/css">
      <script src="rows.js" language="javascript" type="text/javascript"></script>
      <script type="text/javascript" src="jquery.js"></script>



  <!--[if gte IE 5]>
  <link rel="stylesheet" type="text/css" href="IEstyle.css" />
  <![endif]-->


    <script type="text/javascript">callonload();</script>



</head>

【问题讨论】:

    标签: javascript html css internet-explorer


    【解决方案1】:

    没有完全理解你正在做的事情背后的想法,但你需要这个:

    <!--[if !IE]><!-->
    <link rel="stylesheet" href="style.css" type="text/css">
    <!-- <![endif]-->
    
    <!--[if IE]>
    <link rel="stylesheet" type="text/css" href="IEstyle.css" />            
    <![endif]-->
    

    基本上,“IF NOT IE”用于其他样式,“IF IE”用于您想要的样式。

    【讨论】:

      【解决方案2】:

      styles.css 仍然适用于在您的 IE 样式表中未明确覆盖的样式。就像你说的那样,styles.css 总是加载

      防止在 IE 使用中加载 styles.css

      <![if !IE]>
      

      source: MSDN

      条件 cmets 的基础知识:http://www.quirksmode.org/css/condcom.html

      【讨论】:

      • 我正在考虑今后我将把我的整个页面都放在&lt;![if !IE]&gt; :)
      • 谢谢,我不知道我拥有它的方式总是加载 style.css,我认为如果它命中 [if gte IE 5] 它将用 IEstyle.css 替换 style.css跨度>
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-10
      • 1970-01-01
      • 2012-02-12
      • 2012-04-11
      • 2013-07-01
      相关资源
      最近更新 更多