CSS Selector for Child of Parent's Sibling Element

前端 未结 2 631
深忆病人
深忆病人 2021-01-04 00:22

If I\'ve got this:


2条回答
  •  情书的邮戳
    2021-01-04 00:42

    In a word: no.

    Given the current structure of your HTML (and the current state of CSS selectors), this is not possible. Perhaps we will get something like this in CSS4, but traversal like this is best left up to Javascript.

    You can obviously restructure your markup, and use the sibling selector:

    HTML

    Trigger
    Hello

    CSS

    #trigger:hover + .sibling #change {
      color:red; 
    }
    

    codepen

提交回复
热议问题