How can I set CSS only for specific IE browsers?

后端 未结 7 2238
庸人自扰
庸人自扰 2020-12-13 22:24

I have a CSS/jQuery Checkbox style script: http://jsfiddle.net/BwaCD/

The problem is, in current browsers in order for the span to float over the input, the input\'s

相关标签:
7条回答
  • 2020-12-13 23:05

    Conditional comments would work (<!--[if lte IE 8]><stylesheet><![endif]-->), but if you want to do it all in the stylesheet, there is a way:

    body {  
        color: red; /* all browsers, of course */  
        color: green\9; /* IE only */  
    }
    

    The important thing here is the "\9", which has to be exactly "\9". I'm not clear on exactly why this is.

    EDIT: The \9 hack isn't enough by itself. To exclude IE9, you also need the :root hack:

    :root body {
        color: red\9; /* IE9 only */  
    }
    

    Other browsers besides IE might support :root, so combine it with the \9 hack if you're using it to target IE9.

    0 讨论(0)
提交回复
热议问题