Challenge - 5 Problems
SASS Mixin Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate2:00remaining
What is the output CSS of this SASS code using a mixin?
Given the following SASS code, what CSS will be generated in the browser?
SASS
@mixin center { display: flex; justify-content: center; align-items: center; } .box { @include center; width: 100px; height: 100px; background-color: red; }
Attempts:
2 left
💡 Hint
Remember that @include inserts the mixin's styles inside the selector.
✗ Incorrect
The @mixin 'center' defines flexbox centering styles. Using @include center inside .box inserts those styles directly into .box, so the final CSS for .box includes all properties.
🧠 Conceptual
intermediate1:30remaining
What does the @mixin directive do in SASS?
Choose the best description of what @mixin does in SASS.
Attempts:
2 left
💡 Hint
Think about how you avoid repeating the same styles in multiple places.
✗ Incorrect
@mixin lets you write a group of CSS rules once and reuse them by including the mixin in other selectors with @include.
❓ selector
advanced2:00remaining
Which option correctly uses a mixin with parameters?
Given this mixin definition, which usage will produce a blue border of 2px thickness?
@mixin border($color, $width) {
border: $width solid $color;
}
SASS
@mixin border($color, $width) { border: $width solid $color; }
Attempts:
2 left
💡 Hint
Parameters are passed in the order they are defined unless named.
✗ Incorrect
The mixin expects color first, then width. Option A passes blue as color and 2px as width, producing 'border: 2px solid blue;'.
❓ layout
advanced2:30remaining
What visual layout will this SASS code produce?
Consider this SASS code using a mixin for grid layout:
@mixin grid-layout {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 1rem;
}
.container {
@include grid-layout;
background-color: lightgray;
padding: 1rem;
}
What will the .container look like in the browser?
SASS
@mixin grid-layout { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; } .container { @include grid-layout; background-color: lightgray; padding: 1rem; }
Attempts:
2 left
💡 Hint
The mixin sets a grid with 3 equal columns and gaps.
✗ Incorrect
The mixin applies grid display with 3 equal columns and 1rem gaps. The container also has a light gray background and 1rem padding, so visually it is a grid with spacing and background.
❓ accessibility
expert3:00remaining
How can a mixin help improve accessibility in CSS?
Which of these mixin usages best helps maintain accessible focus styles across a website?
Attempts:
2 left
💡 Hint
Accessible focus styles help keyboard users see which element is focused.
✗ Incorrect
Option A defines a visible outline for focus states, improving keyboard navigation accessibility. Other options hide or obscure focus, which is harmful.