CSS selector for element with a specific child :hover'ed
Given this HTML:
<ul class="root">
<li class="a">A</li>
<li class="b">B</li>
</ul>
Is it possible to write a CSS selector that sets properties on .root
when the mouse hovers over .a
?
To be clear, I do NOT mean this:
ul.root li.a:hover { }
This would apply properties to the child when it's hovered over. I want to apply the properties to the root when the child is hovered.
I could fall back on JavaSc开发者_如何学Pythonript, but I'd rather use CSS if it's possible.
This is not possible with CSS alone because, as mentioned in numerous other questions (such as...), there's no CSS parent selector. You'll have to do it with JavaScript.
精彩评论