Challenge - 5 Problems
Animation Mixin Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediateWhat is the output CSS of this Sass animation mixin usage?
Given the Sass code below, what CSS will be generated for the
.box class?SASS
@mixin fadeIn($duration) { animation-name: fadeIn; animation-duration: $duration; animation-fill-mode: forwards; } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } .box { @include fadeIn(2s); }
Attempts:
2 left
💡 Hint
Check how the mixin uses the $duration parameter and the animation-fill-mode property.
✗ Incorrect
The mixin sets animation-name to fadeIn, animation-duration to the passed $duration (2s), and animation-fill-mode to forwards. Option C matches exactly.
🧠 Conceptual
intermediateWhich option correctly explains the benefit of using animation mixins in Sass?
Why do developers use animation mixins in Sass instead of writing animation CSS directly each time?
Attempts:
2 left
💡 Hint
Think about how mixins help with writing CSS faster and cleaner.
✗ Incorrect
Mixins let you write animation code once and reuse it with different values, saving time and avoiding mistakes. They don't automatically optimize or convert animations.
❓ selector
advancedWhich Sass selector usage correctly applies an animation mixin only on hover?
Given the mixin
@mixin slideRight($time), which option applies it only when the user hovers over .menu-item?SASS
@mixin slideRight($time) { animation-name: slideRight; animation-duration: $time; animation-fill-mode: forwards; } @keyframes slideRight { from { transform: translateX(0); } to { transform: translateX(100px); } }
Attempts:
2 left
💡 Hint
Consider Sass nesting and how mixins are included inside selectors.
✗ Incorrect
Option A uses Sass nesting with &:hover inside .menu-item and includes the mixin correctly. Option A is plain CSS syntax, not Sass nesting. Option A applies animation always and pauses on hover. Option A writes CSS manually, not using the mixin.
❓ layout
advancedHow does using animation mixins affect CSS file size and maintainability?
Consider a large project with many animations. What is the main layout-related benefit of using animation mixins in Sass?
Attempts:
2 left
💡 Hint
Think about how mixins help organize code and avoid repetition.
✗ Incorrect
Mixins let you write animation code once and reuse it, so you avoid repeating code manually. This keeps CSS smaller and easier to update. They do not force animations to run together or convert to grid.
❓ accessibility
expertWhich Sass animation mixin pattern best supports users who prefer reduced motion?
How can you write a Sass animation mixin that respects users' system preference for reduced motion?
Attempts:
2 left
💡 Hint
Consider how to completely disable animations for users who want reduced motion.
✗ Incorrect
Option D disables animation entirely with 'animation: none !important;' inside the reduced motion media query, which respects user preference. Other options only pause or shorten animation but do not fully disable it.
