Module 7 · Motion · Lesson 2 of 2

CSS Animations & Keyframes

Advanced ⏱ 30 min2 sections · 1 exercise · 4-question quiz

Transitions need a trigger; animations run on their own. @keyframes defines the choreography, animation properties direct the performance — looping loaders, entrance reveals, ambient motion, all pure CSS.

1. Keyframes + animation

CSS — a bouncing loader
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-18px); }
}
.dot {
  animation: bounce 0.9s ease-in-out infinite;
  /*         name   duration timing    loops */
}

Keyframes are percentage waypoints through one cycle; the browser interpolates between them. The shorthand also accepts a delay, alternate (ping-pong direction), and animation-fill-mode: forwards to hold the final frame — essential for one-shot entrances.

2. Entrances, stagger, and restraint

CSS — fade-up entrance with stagger
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card { animation: fadeUp .5s ease-out both; }
.card:nth-child(2) { animation-delay: .1s; }
.card:nth-child(3) { animation-delay: .2s; }

from/to is shorthand for 0%/100%. Staggered delays turn a grid load into a cascade — the home page tool cards do exactly this. Two rules of taste: animate transform/opacity for smoothness, and always respect prefers-reduced-motion.

💡 Generate ready-made keyframe sets — bounce, pulse, shake, spin and more — in the Keyframe Builder.

3. Try it yourself

Write a @keyframes pulse that scales the circle from 1 to 1.25 at 50% and back, then run it: animation: pulse 1.2s ease-in-out infinite.

exercise.html — editable

4. Quiz — check your understanding

CSS Animations & Keyframes Quiz

4 questions · pass at 60%

Q1. Transitions vs animations:

Transitions interpolate between two states on a trigger; animations follow a keyframe timeline independently.

Q2. animation-iteration-count: infinite makes the animation…

It repeats without end — loaders and ambient effects.

Q3. Holding the final keyframe after a one-shot animation requires…

Without fill-mode forwards (or both), styles snap back when the animation ends.

Q4. from and to in keyframes equal…

They're readable aliases for the 0% and 100% waypoints.
🏆
Quiz passed? You're one step closer to your certificate.

Every lesson quiz you pass (60%+) is saved in your browser and counts toward the CSSmatic Certificate of Completion.

Track my progress →