Challenge - 5 Problems
SASS Mixins 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 with a mixin parameter?
Given the following SASS code, what CSS will be generated?
@mixin box-shadow($x, $y, $blur, $color) {
-webkit-box-shadow: $x $y $blur $color;
box-shadow: $x $y $blur $color;
}
.button {
@include box-shadow(2px, 4px, 5px, rgba(0,0,0,0.3));
}SASS
@mixin box-shadow($x, $y, $blur, $color) { -webkit-box-shadow: $x $y $blur $color; box-shadow: $x $y $blur $color; } .button { @include box-shadow(2px, 4px, 5px, rgba(0,0,0,0.3)); }
Attempts:
2 left
💡 Hint
Remember that CSS box-shadow values are space-separated, not comma-separated.
✗ Incorrect
The mixin inserts the parameters as space-separated values for the box-shadow properties. Option B correctly shows the CSS output with proper units and spacing.
🧠 Conceptual
intermediate2:00remaining
What error occurs if a required mixin parameter is missing?
Consider this SASS mixin:
What happens when you compile this code?
@mixin border-radius($radius) {
border-radius: $radius;
}
.box {
@include border-radius();
}What happens when you compile this code?
SASS
@mixin border-radius($radius) { border-radius: $radius; } .box { @include border-radius(); }
Attempts:
2 left
💡 Hint
Think about what happens when a required parameter is not provided.
✗ Incorrect
SASS requires all parameters without default values to be provided. Omitting $radius causes a compilation error.
❓ selector
advanced2:00remaining
Which CSS selector is generated by this SASS code using a mixin with parameters?
Given this SASS code:
Which CSS selectors appear in the output?
@mixin button-style($color) {
background-color: $color;
color: white;
padding: 1rem;
}
.btn-primary {
@include button-style(blue);
}
.btn-secondary {
@include button-style(gray);
}Which CSS selectors appear in the output?
SASS
@mixin button-style($color) { background-color: $color; color: white; padding: 1rem; } .btn-primary { @include button-style(blue); } .btn-secondary { @include button-style(gray); }
Attempts:
2 left
💡 Hint
Look at how SASS outputs separate selectors for separate blocks.
✗ Incorrect
SASS outputs separate CSS blocks for each selector. The selectors appear one after another, separated by a newline, not combined with commas or spaces.
❓ layout
advanced2:00remaining
How does this mixin with parameters affect layout spacing?
Analyze this SASS code:
What margin layout will the .card element have?
@mixin spacing($top, $right, $bottom, $left) {
margin-top: $top;
margin-right: $right;
margin-bottom: $bottom;
margin-left: $left;
}
.card {
@include spacing(1rem, 2rem, 1rem, 2rem);
}What margin layout will the .card element have?
SASS
@mixin spacing($top, $right, $bottom, $left) { margin-top: $top; margin-right: $right; margin-bottom: $bottom; margin-left: $left; } .card { @include spacing(1rem, 2rem, 1rem, 2rem); }
Attempts:
2 left
💡 Hint
Recall the order of margin properties in CSS: top, right, bottom, left.
✗ Incorrect
The mixin sets each margin side individually using the parameters in the order top, right, bottom, left. The values passed match that order.
❓ accessibility
expert3:00remaining
Which mixin parameter usage best supports accessible focus styles?
You want to create a mixin that applies focus styles with customizable outline color and thickness for accessibility. Which SASS mixin usage produces the best accessible focus style?
@mixin focus-style($color, $thickness) {
outline: $thickness solid $color;
outline-offset: 2px;
}
.button {
@include focus-style(blue, 3px);
}SASS
@mixin focus-style($color, $thickness) { outline: $thickness solid $color; outline-offset: 2px; } .button { @include focus-style(blue, 3px); }
Attempts:
2 left
💡 Hint
Good focus styles must be visible and clear for keyboard users.
✗ Incorrect
Option A uses a solid outline with sufficient thickness and offset, making the focus ring clearly visible and accessible.