Introduction

It specifies the speed curve of the animation. The animation-timing-function uses a mathematical function, called the Cubic Bezier curve, to make the speed curve.
Syntax
animation-timing-function: value;
It has five values: linear, ease, ease-in, ease-out, ease-in-out. Here we discuss all the values of animation-timing-function.
  1. linear: In this case, the animation has the same speed from start to end.
  2. ease: This is the default value. In this case, the animation has a slow start, then fast, before it ends slowly.
  3. ease-in: In this case, the animation has a slow start.
  4. ease-out: In this case, the animation has a slow end.
  5. ease-in-out: In this case, the animation has both a slow start and a slow end.
  1. <html>
  2. <head>
  3. <style type="text/css">
  4. div {
  5. width: 50px;
  6. height: 50px;
  7. background: pink;
  8. color: black;
  9. font-weight: bold;
  10. position: relative;
  11. animation: myfirstmove 5s infinite;
  12. -webkit-animation: myfirstmove 5s infinite;
  13. /* Safari and Google Chrome */
  14. }
  15. #div1 {
  16. animation-timing-function: linear;
  17. }
  18. #div2 {
  19. animation-timing-function: ease;
  20. }
  21. #div3 {
  22. animation-timing-function: ease-in;
  23. }
  24. #div4 {
  25. animation-timing-function: ease-out;
  26. }
  27. #div5 {
  28. animation-timing-function: ease-in-out;
  29. }
  30. /* The following Code is for Safari and Google Chrome: */
  31. #div1 {
  32. -webkit-animation-timing-function: linear;
  33. }
  34. #div2 {
  35. -webkit-animation-timing-function: ease;
  36. }
  37. #div3 {
  38. -webkit-animation-timing-function: ease-in;
  39. }
  40. #div4 {
  41. -webkit-animation-timing-function: ease-out;
  42. }
  43. #div5 {
  44. -webkit-animation-timing-function: ease-in-out;
  45. }
  46. @keyframes myfirstmove {
  47. from {
  48. left: 10px;
  49. }
  50. to {
  51. left: 250px;
  52. }
  53. }
  54. @-webkit-keyframes myfirstmove
  55. /* Safari and Google Chrome */
  56. {
  57. from {
  58. left: 10px;
  59. }
  60. to {
  61. left: 250px;
  62. }
  63. }
  64. </style>
  65. </head>
  66. <body>
  67. <div id="div1">My</div>
  68. <div id="div2">Name</div>
  69. <div id="div3">is</div>
  70. <div id="div4">Mahak</div>
  71. <div id="div5">Gupta</div>
  72. </body>
  73. </html>