当前位置:   article > 正文

css之动画使用 (详解)_css动画

css动画

 闲话我们就不说了,我们直接接入我们的主题:

 基础知识巩固:      

         1. animation-name :xxx (我们的动画名称);

         2. animation-duration : 2s  (动画的持续时间为2s);

         3. animation-timing-function :  linear  (动画运动的曲线);

            匀速: linear

            低速开始—>加速—>结束前减速 :ease (系统默认)

            以低速开始 :ease-in 

            以低速结束 :ease-out

            以低速开始和结束 : ease-in-out

         4. animation-delay :  1s (动画等待1s后开始);

         5. animatiom-iteration-count :  1 (动画播放次数为1次);

            无限次执行 : infinite

         6. animation-direction :  nomal (设置动画执行规则);

            系统默认 :   nomal 

            往返动画,执行完一次之后往回执行下一次 : alternate

            反向执行 : reverse

         7. animation-fill-mode :  none (动画结束的最后一帧);

            不做任何改变 :  none

            让元素结束状态保持动画最后一帧的样式 : forwards

            让元素等待状态的时候显示动画第一帧的样式 : backwards

            等待状态显示第一帧,结束状态保持最后一帧 : both

         8. animation-fill-mode :  none (设置动画是否暂停);

            执行动画:  running

            暂停动画:  paused

     动画使用  简写 : 

animation : 动画名称、时间、运动曲线、等待时长、播放次数、执行规则、动画帧、是否暂停。

     使用案例 :

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>animation 方法介绍</title>
  8. <style>
  9. .box{
  10. margin: 0 auto;
  11. color: white;
  12. text-align: center;
  13. height: 50px;
  14. line-height: 50px;
  15. background-color: red;
  16. cursor: pointer;
  17. animation:mymove 5s linear forwards;
  18. }
  19. /* 动画关键帧 */
  20. .box:hover {
  21. /* 设置动画是否暂停*/
  22. animation-play-state: paused;
  23. }
  24. @keyframes mymove{
  25. from {width: 0px;}
  26. to {width: 100%;}
  27. };
  28. /* @keyframes mymove{
  29. 0% {width: 0px;}
  30. 25% {width: 25%;}
  31. 50% {width: 50%;}
  32. 75% {width: 75%;}
  33. 100% {width: 100%;}
  34. } */
  35. </style>
  36. </head>
  37. <body>
  38. <div class="box">测试效果,只做演示使用</div>
  39. </body>
  40. </html>

       效果展示 :

         

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/266261?site
推荐阅读
相关标签
  

闽ICP备14008679号