【发布时间】:2015-11-08 21:25:39
【问题描述】:
我写过这样的动画代码:
.bounce {
-webkit-animation-name: bounce;
-moz-animation-name: bounce;
-o-animation-name: bounce;
animation-name: bounce;
animation-duration: 1s;
animation-timing-function: ease-in-out;
animation-delay: 0s;
animation-iteration-count: 0;
animation-direction: alternate;
animation-play-state: paused;
}
.bounce:hover {
animation-play-state:running;
animation-iteration-count: 1;
}
@keyframes bounce {
0%, 20%, 50%, 80%, 100% {transform: translateY(0);opacity: 1;}
40% {transform: translateY(-20px);}
60% {transform: translateY(-10px);}
}
并将“反弹”类分配给我页面上的按钮。当我将鼠标悬停在它上面时,它有一个漂亮的小弹跳动画,但是当我再次将鼠标悬停在它上面时,它就不会播放了。每次将鼠标悬停在它上面时,我该怎么做才能让它弹跳?
【问题讨论】:
-
尝试删除
animation-iteration-count: 1;。您不会在悬停时删除动画,而只是暂停它。这意味着浏览器将保留有关号码的信息。已完成的迭代次数。因此,当一个迭代完成时,它不会进一步执行。