CSS Selector for Child of Parent's Sibling Element

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

If I\'ve got this:


2条回答
  •  误落风尘
    2021-01-04 00:37

    No. You cannot achieve this using CSS only. Javascript is a good option in this case..

    You can however detect the .parent being hovered (which will solve your problem if the parent surrounds exactly the trigger):

    .parent:hover + .sibling div#change{background:red;}
    

    (markup stays the same jsFiddle)

提交回复
热议问题