我怎样才能得到一个CSS伪元素:检查工作在没有Javascript的IE8? [英] How can I get a css pseudo element :checked to work in IE8 without Javascript?

查看:105
本文介绍了我怎样才能得到一个CSS伪元素:检查工作在没有Javascript的IE8?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个单选按钮,我需要点击设置背景颜色。我的代码适用于除IE8以外的所有浏览器。这是可能得到这个IE8的工作,而不使用Javascript?

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 of Javascript?

<form>
    <input type="radio" id="m" name="gender" value="male">
    <label for="m">male</label>
    <input type="radio" id="f" name="gender" value="female">
    <label for="f">female</label>
</form>

input:checked + label{
    background:red;
}

http://jsfiddle.net/chrimbus/sXjyL/3/

http://jsfiddle.net/chrimbus/sXjyL/3/

推荐答案

尽管IE8 了解邻近兄弟选择器,它不明白 已检查伪元素,所以,不幸的是,你不能通过使用CSS来使你的代码对IE8友好。

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.

看看 Selectivizr IE7.js 为JavaScript解决方案。

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

这篇关于我怎样才能得到一个CSS伪元素:检查工作在没有Javascript的IE8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆