0
0
CSSmarkup~20 mins

Keyframe animations in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Keyframe Animation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
Identify the correct syntax for defining a keyframe animation
Which option correctly defines a keyframe animation named slide that moves an element from left to right?
A@keyframes slide { start { left: 0; } end { left: 100px; } }
B@keyframe slide { 0% { left: 0; } 100% { left: 100px; } }
C@keyframes slide { 0 { left: 0; } 100 { left: 100px; } }
D@keyframes slide { from { left: 0; } to { left: 100px; } }
Attempts:
2 left
💡 Hint
Remember the correct keyword is @keyframes and the steps use from and to or percentages.
rendering
intermediate
2:00remaining
What is the visual result of this animation?
Given the CSS below, what will you see when the animation runs on a box?
CSS
div {
  position: relative;
  width: 100px;
  height: 100px;
  background-color: blue;
  animation: fade 2s forwards;
}

@keyframes fade {
  from { opacity: 1; }
  to { opacity: 0; }
}
AThe blue box gradually disappears by becoming transparent over 2 seconds.
BThe blue box moves 100px to the right over 2 seconds.
CThe blue box changes color from blue to red over 2 seconds.
DThe blue box grows in size from 100px to 200px over 2 seconds.
Attempts:
2 left
💡 Hint
Look at the opacity property in the keyframes.
selector
advanced
2:00remaining
Which CSS selector applies the animation only when the element is hovered?
You want an animation named grow to run only when the user hovers over a button. Which CSS rule correctly applies this?
Abutton:hover { animation: grow 1s forwards; }
Bbutton::hover { animation: grow 1s forwards; }
Cbutton:active { animation-name: grow; animation-duration: 1s; }
Dbutton { animation: grow 1s forwards; }
Attempts:
2 left
💡 Hint
The hover state uses a pseudo-class, not a pseudo-element.
layout
advanced
2:00remaining
How does the animation-fill-mode: forwards; affect the element after animation ends?
Consider an animation that moves a box from left to right. What does animation-fill-mode: forwards; do after the animation finishes?
AThe box immediately returns to its original position before animation.
BThe box disappears from the page after animation ends.
CThe box stays at the final position defined in the last keyframe.
DThe box blinks continuously after animation ends.
Attempts:
2 left
💡 Hint
Think about whether the element keeps the last style or resets.
accessibility
expert
3:00remaining
What is the best practice to make keyframe animations accessible for users sensitive to motion?
Which CSS approach respects users who prefer reduced motion and disables animations accordingly?
AUse JavaScript to detect user preference and remove animations dynamically.
B@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
CAdd <code>aria-hidden="true"</code> to animated elements to hide them from screen readers.
DSet animation duration to 0.1s for all animations to minimize motion.
Attempts:
2 left
💡 Hint
There is a CSS media query for motion preferences.