简体   繁体   中英

How can I load only a single specific style sheet when using Internet Explorer?

In the case the html is opened in IE I want to use a different style sheet ONLY. However, it seems that it is pulling some elements properties from style.css as well. How can this be? Doesn't the [if gte IE 5] ensure only IEstyle.css is used? What is the best way to fix this?
Thanks.

<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>

Not totally getting the thinking behind what you are doing, but you need this:

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

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

Basically, "IF NOT IE" for the other styles, and "IF IE" for the styles you want.

styles.css still applies for styles that are not explicitly overridden in your IE stylesheet. The way you put it, styles.css gets always loaded.

To prevent loading styles.css in IE use

<![if !IE]>

source: MSDN

Basics on conditional comments: http://www.quirksmode.org/css/condcom.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM