How to apply the Hover effect to an element immediately before?

Asked

Viewed 34 times

0

I have the following structure:

<div>
   <img src="#">
   <button>Teste</button>
</div>
<div>
   <img src="#">
   <button>Teste</button>
</div>

I need that when resting the mouse on a button in the image immediately before it is applied the effect transform:scale(1.5)

  • What have you tried to do? Put the code in the question

1 answer

0

Do you want to apply the effect on the image or button? If you want the effect on the button just replace img for button. Would that be your question?

img:hover {
  transform: scale(1.5);
}
<div>
   <img src="#">
   <button>Teste</button>
</div>
<div>
   <img src="#">
   <button>Teste</button>
</div>

  • No, hover the mouse over the button and apply the effect to the image

  • I can do it with the element immediately after, but immediately before I can’t do it

Browser other questions tagged

You are not signed in. Login or sign up in order to post.