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

前端 未结 4 1335
温柔的废话
温柔的废话 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:22

    There is actualy no way to do it in pure CSS.

    But, you could simply do the following :

    
    

    And then apply the :hover effect to the a tag.

    Another way will be with some javascript. For example, with the jquery selector .closest()

提交回复
热议问题