在& lt; a& gt;上更改颜色内部& lt; div& gt;当选中单选按钮时? [英] Changing color on <a> inside <div> when radio button is checked?
问题描述
在选中第一个单选按钮时,尝试更改< a>
标记上的属性时遇到了一些麻烦。当我想更改一个< label>
属性但不使用< a> $ c $时,它可以很好地工作c>
I'm having some trouble trying to change a property on the <a>
tag when the first radio button is checked. It works fine when I want to change a <label>
property when one is checked but not with the <a>
有人可以帮我吗?
推荐答案
+
选择器意味着两个元素之间不能有任何其他元素。 +标签
起作用的原因是,您的标签
紧接在单选按钮之后。但是,标签
介于您的单选按钮和 div
之间,因此#radio-一个:选中+ div
不起作用。
The +
selector means there must not be any other elements coming between the two elements. The reason + label
works is because your label
comes immediately after your radio button. However, that label
is standing between your radio button and the div
, so #radio-one:checked + div
won't work.
您需要使用
#radio-one:checked + label + div a
另请参见< a href = https://stackoverflow.com/questions/3382078/what-does-mean-in-css/3382096#3382096>此答案以举例说明 +
选择器有效。
Also see this answer for an illustration on how the +
selector works.
这篇关于在& lt; a& gt;上更改颜色内部& lt; div& gt;当选中单选按钮时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!