CSS Animations & Keyframes
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
@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
@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.
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.
4. Quiz — check your understanding
CSS Animations & Keyframes Quiz
4 questions · pass at 60%Q1. Transitions vs animations:
Q2. animation-iteration-count: infinite makes the animation…
Q3. Holding the final keyframe after a one-shot animation requires…
Q4. from and to in keyframes equal…
Every lesson quiz you pass (60%+) is saved in your browser and counts toward the CSSmatic Certificate of Completion.