当前位置:Gxlcms > css > animation-timing-function属性有什么用

animation-timing-function属性有什么用

时间:2021-07-01 10:21:17 帮助过:38人阅读

animation-timing-function属性是用来设置动画的速度曲线,它可以设置动画速度为匀速、以低速开始、以低速结束、以低速开始和结束、先慢后快再变慢或者是自己自定义数值。

CSS3 animation-timing-function属性

作用:

animation-timing-function 规定动画的速度曲线。速度曲线定义动画从一套 CSS 样式变为另一套所用的时间。速度曲线用于使变化更为平滑。

语法:

  1. animation-timing-function: value;

说明:

animation-timing-function 使用名为三次贝塞尔(Cubic Bezier)函数的数学函数,来生成速度曲线。您能够在该函数中使用自己的值,也可以预定义的值:

linear:动画从头到尾的速度是相同的。

ease:默认值。动画以低速开始,然后加快,在结束前变慢。

ease-in:动画以低速开始。

ease-out:动画以低速结束。

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

cubic-bezier(n,n,n,n):在 cubic-bezier 函数中自己的值。可能的值是从 0 到 1 的数值。

注:Internet Explorer 9 以及更早的版本不支持 animation-timing-function 属性。

CSS3 animation-timing-function属性的使用示例

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style>
  5. div
  6. {
  7. width:100px;
  8. height:100px;
  9. background:red;
  10. position:relative;
  11. animation:mymove 5s infinite;
  12. animation-timing-function:linear;
  13. /* Safari and Chrome */
  14. -webkit-animation:mymove 5s infinite;
  15. -webkit-animation-timing-function:linear;
  16. }
  17. @keyframes mymove
  18. {
  19. from {left:0px;}
  20. to {left:200px;}
  21. }
  22. @-webkit-keyframes mymove /* Safari and Chrome */
  23. {
  24. from {left:0px;}
  25. to {left:200px;}
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <div></div>
  31. </body>
  32. </html>

效果图:

1.gif

以上就是本篇文章的全部内容,希望能对大家的学习有所帮助。更多精彩内容大家可以关注Gxl网相关教程栏目!!!

以上就是animation-timing-function属性有什么用的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行