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?
Given the Sass code below, what CSS will be generated after compilation?
SASS
@mixin fancy-text { color: red; font-weight: bold; } .title { @include fancy-text; font-size: 2rem; }
Attempts:
2 left
💡 Hint
Remember that @include inserts the mixin's styles inside the selector where it is called.
✗ Incorrect
The @include directive copies the mixin's CSS properties inside the .title selector. So the final CSS has color, font-weight, and font-size all inside .title.
🧠 Conceptual
intermediate2:00remaining
What happens if you include a mixin with parameters incorrectly?
Consider this mixin with a parameter:
@mixin box-shadow($shadow) {
box-shadow: $shadow;
}
Which option will cause an error when including this mixin?
Attempts:
2 left
💡 Hint
Mixins with parameters require you to pass arguments when including.
✗ Incorrect
Option A calls the mixin without passing the required parameter, causing a compilation error. The other options correctly pass the parameter either positionally or by name.
❓ selector
advanced2:00remaining
Which option correctly includes a mixin inside a nested selector?
Given this Sass code, which option produces the correct CSS output?
SASS
@mixin highlight { background-color: yellow; } .article { p { @include highlight; } }
Attempts:
2 left
💡 Hint
Nested selectors in Sass compile to combined selectors in CSS.
✗ Incorrect
The nested p inside .article with the included mixin compiles to .article p with the background-color style. Option B matches this output exactly.
❓ layout
advanced2:00remaining
How does including a mixin affect layout styles in this example?
Look at this Sass code with a mixin for flexbox layout:
@mixin flex-center {
display: flex;
justify-content: center;
align-items: center;
}
.container {
@include flex-center;
height: 10rem;
}
What will the container look like in the browser?
Attempts:
2 left
💡 Hint
Flexbox with justify-content and align-items set to center centers content both ways.
✗ Incorrect
The mixin sets display:flex and centers content horizontally and vertically. The container has height 10rem, so content is perfectly centered inside that box.
❓ accessibility
expert2:00remaining
Which mixin inclusion best supports accessible focus styles?
You have this mixin for focus styles:
@mixin focus-ring {
outline: 3px solid blue;
outline-offset: 2px;
}
Which option correctly includes this mixin to improve keyboard accessibility on buttons?
Attempts:
2 left
💡 Hint
Focus styles should apply only when the element receives keyboard focus.
✗ Incorrect
Option D applies the focus-ring styles only when the button is focused, which helps keyboard users see where focus is. Other options apply styles on hover or active states, which do not help keyboard navigation.