Is there a css selector for selecting an element futherup in the html?

前端 未结 4 1333
温柔的废话
温柔的废话 2020-11-29 13:02

In the following HTML, I want to apply a hover effect to the header h2, upon hover of the image img. Is there a css selector to do that, or another

4条回答
  •  暖寄归人
    2020-11-29 13:39

    "Is there a css selector to do that?"

    This doesn't exist in the current state of CSS yet (as of Selectors Level 3) .. but when Selectors Level 4 is more widely implemeneted, there will be a parent selector:

    E! > F - "An E element, parent of an F element"
    

    Unfortuntely it will be quite some time before this is implemented as the Module is still in the Working Draft stage ..

提交回复
热议问题