There is. Basically you will need to create the gif yourself using individual frames. Essentially, you create X number of frames, then use keyframes
to cycle through them as background-image
properties of an absolutely positioned div. The "gif" starts with the property animation-play-state:paused
and changes to running
on hover. It is possible to switch these properties obviously. Consider the following:
Your markup:
<div class="gif"></div>
And your CSS:
.gif {
position: absolute;
margin: auto;
background-image: url(/path/to/starting.frame);
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
animation: play 0.5s infinite steps(1);
animation-play-state: paused;
}
.gif:hover {
animation-play-state:running;
}
@keyframes play {
0% { background-image: url('/path/to/0.frame'); }
15% { background-image: url('/path/to/1.frame'); }
30% { background-image: url('/path/to/2.frame'); }
45% { background-image: url('/path/to/3.frame'); }
60% { background-image: url('/path/to/4.frame'); }
75% { background-image: url('/path/to/5.frame'); }
90% { background-image: url('/path/to/6.frame'); }
100% { background-image: url('/path/to/7.frame'); }
}
Here is an example I was able to find and alter.