R
R
retrica2015-02-08 13:22:19
css
retrica, 2015-02-08 13:22:19

How to make a gif animation appear instead of it when hovering over a png image?

The site has a png image, so that when you hover over it, another gif image appears.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
More916, 2015-02-08
@More916

Or replace the element with a div with a background:

.myImg {
  background: url('static.png');
}
.myimg:hover { 
  background: url('animation.gif');
}

Or via js, like this:
<img src="static.png" onmouseenter="this.src='animation.gif'" onmouseleave="this.src='static.png'">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question