Can I use img:hover to get another element?

前端 未结 5 1576
青春惊慌失措
青春惊慌失措 2021-01-25 10:33

So is it possible to make this work

#element img:hover #otherelement {...}

like

#element:hover #otherelement {...}
5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-25 11:09

    What your first selector is looking for is something called #otherelement inside an image. Images can't have child elements.

    If the element is a sibling of the image, you might want to try img:hover~#otherelement or img:hover+#otherelement.

提交回复
热议问题