如何使用:checked css为我的单选按钮添加隐藏的输入按钮? http://cormilu.com.br/loja/sem-categoria/test-2/
我试过了:
input[type=”radio”]:checked{ color:red; … }
input[type="radio"]:checked+label{ color:red; … }
label > input + img{ color:red; … }
label > input:checked + img{color:red; … }
是否因为我的页面设置? Ihid输入单选按钮并用图像替换它们。
感谢您的帮助。 干杯, 阿米尔
答案 0 :(得分:2)
问题在于,您无法定位图像或已替换单选按钮的标签。
你可以:
1)使用JavaScript在点击/更改单选按钮时更改内容(定位parentNode
2)如果能够解决问题,请更改HTML标记,并应用CSS:
在<img>
之后移动<input>
标记并使用CSS同级选择器(+
):
<强> HTML:强>
<label class="hideradio-vars">
<input type="radio" value="20-bolas-fio-de-3m" id="pa_kit" name="attribute_pa_kit">
<img src="http://cormilu.com.br/cormilu-content/uploads/2015/04/free1.png">
20 Bolas Fio de 3m
</label>
<强> CSS:强>
.hideradio-vars input[type="radio"]:checked + img {
/* Your rules here */
}
不幸的是,您无法使用CSS定位父级,因此您可能需要查看JS / jQuery或完全修改HTML标记。