【发布时间】:2013-11-01 00:44:54
【问题描述】:
我这里有一个选择器:
input[type=radio]:checked + label:before {
content: "\2022";
color: #913921;
font-size: 20px;
text-align: center;
line-height: 18px;
}
这不起作用,因为下面的 IE8 不支持 css 中的伪类选择器我试过 http://selectivizr.com/ 但没有运气:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!--[if (gte IE 6)&(lte IE 8)]>
<script type="text/javascript" src="js/selectivizr.js"></script>
<style type="text/css">
input[type=radio]:checked + label:before {
content: "\2022";
color: #913921;
font-size: 20px;
text-align: center;
line-height: 18px;
}
</style>
<![endif]-->
我已经把 <!doctype html> 像其他人所说的那样让 selectivizr 工作了。
是否有任何可能的解决方案,例如 jQuery,或者 selectivizr 有什么问题?
我想出了这个解决方案。
$("#radioDivWrapper input:radio[name=option_radioDivWrapper]").change(function()
{
var id = $(this).attr("id");
$('#radioDivWrapperlabel').removeClass('selectedR');
$('#radioDivWrapperlabel[for='+id+']').addClass('selectedR');
});
只需添加一个类来设置输入类型单选的标签样式。
【问题讨论】:
-
你不能用 jQuery 做这个选择,而且我对 Selectivizr 不熟悉。您是否有机会只重构 HTML(和/或 CSS),以便不需要使用这样的选择器?你想完成什么?
-
另外,你确定 Selectivizr 支持
:before吗?我没有在他们的网站上看到它,也没有在源代码中看到对它的引用。此外,IE8 确实支持:before- 这是您唯一需要支持的浏览器吗? developer.mozilla.org/en-US/docs/Web/CSS/::before -
我想要完成的是将样式放在选中的输入单选类型的标签上
-
你能告诉我们你想做什么,你的
html是什么样子的吗? -
现在我希望你能找到解决方案。但除此之外,这是我的方法:尝试将标签和复选框放在一个 div 和复选框的 onselect 中,您可以为该标签分配一个样式。 (复选框 > getParent > child
或类似的。)
标签: javascript jquery css internet-explorer internet-explorer-8