CSS animation-timing-function
Property
The animation-timing-function
property in CSS controls the speed curve of an animation. It defines how an animation accelerates and decelerates during its duration.
1. Syntax
2. Accepted Values
Value | Description |
---|---|
ease (default) | Starts slow, speeds up in the middle, and then slows down at the end. |
linear | Constant speed from start to finish. |
ease-in | Starts slow and then speeds up. |
ease-out | Starts fast and then slows down. |
ease-in-out | Starts and ends slowly, with a fast middle. |
steps(n, start/end) | Jumps in n steps instead of smooth animation. |
cubic-bezier(x1, y1, x2, y2) | Custom speed curve using a Bezier function. |
3. Example – Using ease
(Default)
✅ The movement starts slow, speeds up, and then slows down.
4. Example – Using linear
(Constant Speed)
✅ The movement speed stays constant throughout.
5. Example – Custom Bezier Curve (cubic-bezier
)
✅ Allows precise control over the animation’s acceleration.
6. Best Practices
✔ Use ease-in-out
for smooth, natural motion.
✔ Use linear
for continuous animations (like a loading spinner).
✔ Use cubic-bezier
for fine-tuned motion effects.