const animated = document.getElementById('c');
animated.onmouseenter = () => {
// Need to remove the animation after its done, otherwise
// It won't play again when the mouse is hovering on the element.
setTimeout(() => animated.style.animation = '', 1000);
animated.style.animation = 'rotate 1s ease';
}
1条答案
按热度按时间2skhul331#
我想出了解决办法,我用JavaScript在时间过去后删除动画。