Is it possible to restart an animated GIF used as background-image
?
Consider this HTML:
<div id="face">
<div id="eyes"></eyes>
</div>
And this style:
#eyes.blink {
background-image:url('blink.gif');
}
I would like the blink.gif
animation to play every time I add the class blink
to #eyes
, not just the first time.
I expected this to work:
function startBlink() {
$('#eyes').addClass('blink');
}
function stopBlink() {
$('#eyes').removeClass('blink');
}
The problem is that both Firefox and WebKit browser do not play a background-image GIF animation again once it has played once. Adding/removing the class blink only works the first time.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…