0

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%;
}
2
  • 1
    This might help. stackoverflow.com/questions/10352217/… Commented Sep 24, 2012 at 13:38
  • 1
    I copied your title into google and got: "About 2,210,000 results" the first of which answers this question. Commented Sep 24, 2012 at 13:40

4 Answers 4

3

What you're looking for is conditional comments:

<!--[if IE 9]>
<style type="text/css">
  IE specific CSS rules go here
</style>
<![endif]-->
Sign up to request clarification or add additional context in comments.

Comments

3

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

3 Comments

If you apply it on the html tag you will have problems with windows phone, who IE doesn't like to see anything in the <html> tag. I tested myself, so the best option is to use it on the <body> tag.
This is probably one of the better ways to go. It doesn't require an extra HTTP request like loading an extra CSS file would.
2

Use IE conditional comments:

<!-- [if ie 9]>
 CSS that you want to be IE only
<![endif]>-->

2 Comments

I have to create a file specific to solve this? Or i can use those tags inside my ie.css file?
You could have in that if statement the link to your ie.css. Or, as others have said, you could go a different route and change your HTML class, like this: paulirish.com/2008/…
1

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

1 Comment

i would suggest the conditional css rule

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.