如何防止css3动画重置完成后?

前端之家收集整理的这篇文章主要介绍了如何防止css3动画重置完成后?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
参见英文答案 > Stopping a CSS3 Animation on last frame5个答案我写一个css3动画,它只执行一次。动画效果很好,但是当动画完成时它会重置。如何避免这种情况,我想保留结果而不是重置它。
  1. <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  2. <script>
  3. $(function(){
  4. $("#fdiv").delay(1000).addClass("go");
  5. });
  6. </script>
  7.  
  8. <style>
  9. #fdiv{
  10. width: 10px;
  11. height: 10px;
  12. position: absolute;
  13. margin-left: -5px;
  14. margin-top: -5px;
  15. left: 50%;
  16. top: 50%;
  17. background-color: red;
  18. }
  19.  
  20. .go{
  21. -webkit-animation: spinAndZoom 1s 1;
  22. }
  23.  
  24. @-webkit-keyframes spinAndZoom {
  25. 0% {
  26. width: 10px;
  27. height: 10px;
  28. margin-left: -5px;
  29. margin-top: -5px;
  30. -webkit-transform: rotateZ(0deg);
  31. }
  32. 100% {
  33. width: 500px;
  34. height: 500px;
  35. margin-left: -250px;
  36. margin-top: -250px;
  37. -webkit-transform: rotateZ(360deg);
  38. }
  39. }
  40. </style>
  41.  
  42. <div id="fdiv">
  43.  
  44. </div>

这是demo.Thx!

解决方法

添加动画填充模式:转发;

到你的.go

The animation’s final keyframe continues to apply after the final iteration of the animation completes.

http://css-infos.net/property/-webkit-animation-fill-mode

猜你在找的CSS相关文章