Apply css styles only to ie9

2019-09-07 05:30发布

im my website i have a file (ie.css) to correct css problems of the ie. However, now i have a litte problem. Some default styles of the website are good on ie8 and not on ie9.

So, i would like to apply the follow css code inside the file "ie.css" only to the ie version 9, is that possible?

.ngg-galleryoverview {
    overflow: hidden;
    margin-top: 10px;
    width: 100%;
    clear:both; 
    display:block !important;
    /*border: 2px solid #ADE132;*/
    /*margin-left: 10px;*/
    margin-left: 2%;
}

.ngg-gallery-thumbnail {
    float: left;
    margin-right: 3%;
    /*margin-right: 10px;*/
    text-align: center;
    /*border: 2px solid #ADE132; */
    height: 430%;
    width: 430%;
}

4条回答
The star\"
2楼-- · 2019-09-07 06:10

What you're looking for is conditional comments:

<!--[if IE 9]>
<style type="text/css">
  IE specific CSS rules go here
</style>
<![endif]-->
查看更多
Evening l夕情丶
3楼-- · 2019-09-07 06:10

Use IE conditional comments:

<!-- [if ie 9]>
 CSS that you want to be IE only
<![endif]>-->
查看更多
Ridiculous、
4楼-- · 2019-09-07 06:11

The best way to do this is to set a body class only for IE9 and when you want to modify your css it will begin wit that class in front any other html tag or class. This will guarantee that your css is w3c compliant.

Here's the code for that:

<!--[if IE 9 ]>    <body class="ie9"> <![endif]-->
查看更多
家丑人穷心不美
5楼-- · 2019-09-07 06:19

Try in css like

:root .classname{ color:pink \0/IE9; } /* IE9 */

OR write in head tag

<!--[if IE 9]>
<style>
Special instructions for IE 9 here
</style>

<![endif]-->
查看更多
登录 后发表回答