How can I get a css pseudo element :checked to work in IE8 without Javascript?

前端 未结 2 1098
甜味超标
甜味超标 2021-02-20 02:06

I have two radio buttons, I need to set the background color on click. My code works in all browsers except for IE8. Is this possible to get this to work for IE8 without the use

相关标签:
2条回答
  • 2021-02-20 02:40

    While IE8 understands adjacent sibling selectors, it doesn't understand the checked pseudo-element, so, unfortunately, you can't make your code IE8-friendly by using CSS only.

    Take a look at Selectivizr or IE7.js for a JavaScript solution.

    0 讨论(0)
  • 2021-02-20 02:42

    You can try this:

    input[checked=checked] + label{
        background:red;
    }
    
    0 讨论(0)
提交回复
热议问题