开发者

Rollover child changes parent

开发者 https://www.devze.com 2023-03-12 10:48 出处:网络
Is there a way through pure CSS to change the style of a parent LI on the hover of a child LI? <ul>

Is there a way through pure CSS to change the style of a parent LI on the hover of a child LI?

<ul>
  <li>
    1
    <ul>
      <li>10</li>
      <li> 20</li>
    </ul>
 开发者_如何学编程 </li>
  <li>2</li>
</ul>

So that when I hover over 10 or 20, a style is applied to 1 or 2?


No, there is no parent selector in CSS.

See here for why this is the case:

http://snook.ca/archives/html_and_css/css-parent-selectors

In short: performance reasons.

0

精彩评论

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

关注公众号