根据 http://www.w3schools.com/cssref/sel_not.asp IE9 支持“not”选择器 但是,以下内容在 ie9 中不起作用:
HTML:
<input type="checkbox"><span>I agree to the terms and conditions</span>
CSS:
input:not(:checked) + span
{
font-weight:bold;
text-decoration:underline;
color:red;
}
当您选中该复选框时,样式仍会应用。在其他浏览器(FF、Chrome)中,它按预期工作。
这是 IE9 的某种错误吗?
谢谢。
最佳答案
我不知道这个错误到底是什么,但我有一个解决方法。
通过一些实验我发现如果你把这条线
input:checked + p {}
在您的 CSS 之上,您的 CSS 在 IE 中运行良好。所以我建议你把它放进去然后忘记它,除非你想投入大量时间来找出错误的确切程度。
input:checked + p {}
input:not(:checked) + span {
font-weight: bold;
text-decoration: underline;
color: red;
}
<input type="checkbox"><span>I agree to the terms and conditions</span>
为了测试,您可以注释掉第一行,然后它在 IE 中停止工作。
关于html - ie9 中的 'not' css 选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30934107/