开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜