Maintaining the final state at end of a CSS3 animation
I'm running an animation on some elements that are set to opacity: 0;
in the CSS. The animation class is applied onClick, and, using keyframes, it changes the opacity from 0
to 1
(among other things).
Unfortunately, when the animation is over, the elements go back to opacity: 0
(in both Firefox and Chrome). My natural thinking would be that animated elements maintain the final state, overriding their original properties. Is this not true? And if not, how can I get the element to do so?
The code (prefixed versions not included):
@keyframes bubble {
0% { transform:scale(0.5); opacity:0.0; }
50% { transform:scale(1.2); opacity:0.5; }
100% { transform:scale(1.0); opacity:1.0; }
}
Try adding animation-fill-mode: forwards;
. For example like this:
animation: bubble 1.0s forwards;
-webkit-animation: bubble 1.0s forwards; /* for less modern browsers */
If you are using more animation attributes the shorthand is:
animation: bubble 2s linear 0.5s 1 normal forwards;
for 2s duration, linear timing-function, 0.5s delay, 1 iteration-count, normal direction, forward fill-mode
链接地址: http://www.djcxy.com/p/70460.html上一篇: 在Chrome中更改JavaScript的占位符颜色
下一篇: 在CSS3动画结束时保持最终状态