CSS animation-timing-function
Published Jul 8, 2021Updated Dec 8, 2023
Specifies how intermediate values are calculated throughout the duration of an animation, determining the pacing of the animation. This CSS property influences the speed curve of the animation, controlling its acceleration and deceleration.
Syntax
animation-timing-function: value;
where value can be one of the following keywords:
step-start: Easing curve for an animation that starts quickly and decelerates.step-end: Easing curve for an animation that starts slowly and decelerates.linear: Easing curve for an animation that maintains a constant speed.ease: Easing curve for an animation that starts and ends smoothly.ease-in: Easing curve for an animation that starts slowly and accelerates.ease-out: Easing curve for an animation that starts quickly and decelerates.ease-in-out: Easing curve for an animation that starts and ends smoothly.cubic-bezier(): Easing curve defined using cubic Bezier functions.
Note: Applied property by property from keyframe to keyframe.
Example 1
Applying ease-in-out to the animation-timing-function property of a div element:
div {height: 100px;width: 100px;border-radius: 50%;background-color: blue;animation-name: slideright;animation-duration: 4s;animation-iteration-count: infinite;animation-timing-function: ease-in-out;}@keyframes slideright {0% {margin-left: 0%;}50% {margin-left: 50%;}100% {margin-left: 100%;}}
The ease-in-out timing function adds a gradual acceleration and deceleration effect to make the motion appear more natural.

Learn CSS on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- A full-stack engineer can get a project done from start to finish, back-end to front-end.
- Includes 51 Courses
- With Professional Certification
- Beginner Friendly.150 hours