简体   繁体   中英

Conditional comments for CSS in IE9

I want to add a specific style sheet for IE9 which overrides the img.icon css class with different margin values. So i add the below in the head section. But when page loads it display as a text in browser.

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

You are missing the <style> tags

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

it think

You forgot the style tags.

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

Also, you might find it easier to load an external stylesheet within the conditional comments:

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

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