且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在< a>上更改颜色内部< div>当单选按钮被选中?

更新时间:2022-11-21 10:54:48

code> + 选择器意味着两个元素之间不能有任何其他元素。原因 + label 的工作原因是您的标签紧接在单选按钮之后。然而,标签位于单选按钮和 div 之间,因此#radio-

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

更新了小提示

另请参阅此答案,说明 + selector工作。

Also see this answer for an illustration on how the + selector works.