Course contentsShow
← Web Development
Lesson 519 of 2,9829. CSS Transitions and AnimationsFree lesson

The animation-timing-function

Apply easing functions to control the acceleration curve throughout the animation.

The animation-timing-function

You'll learn how to control the speed curve of an animation so it feels smooth, bouncy, or dramatic.

What Is animation-timing-function?

Just like transition-timing-function controls how a transition accelerates, animation-timing-function controls the pacing of a keyframe animation. It determines whether your animation moves at a constant speed, starts slow and speeds up, or follows a custom rhythm.

Think of it like driving: you don't instantly jump to 60 mph—you accelerate smoothly. Similarly, animations feel more natural when they ease in, ease out, or follow a specific acceleration curve.

Core Syntax

.element {
  animation-name: slideIn;
  animation-duration: 2s;
  animation-timing-function: ease-in-out;
}

Common Values

  • linear – constant speed from start to finish
  • ease – slow start, fast middle, slow end (default)
  • ease-in – slow start, then accelerates
  • ease-out – fast start, then decelerates
  • ease-in-out – slow start and end, fast middle

You can also use cubic-bezier() for fully custom curves, just like you learned with transitions.

Example

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-50px); }
}

.ball {
  animation-name: bounce;
  animation-duration: 1s;
  animation-timing-function: ease-out; /* Starts fast, slows down */
}

This makes the ball shoot up quickly, then gently settle at the top—much more realistic than linear.

Key Takeaway: animation-timing-function shapes how your keyframe animation accelerates over time, making motion feel natural or stylized instead of robotic.