Challenge - 5 Problems
Responsive Breakpoint Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding breakpoint mixin usage
Given this Sass mixin for a responsive breakpoint:
What CSS will be generated by this Sass code?
@mixin respond-to($breakpoint) {
@if $breakpoint == small {
@media (max-width: 600px) { @content; }
} @else if $breakpoint == medium {
@media (min-width: 601px) and (max-width: 1024px) { @content; }
} @else if $breakpoint == large {
@media (min-width: 1025px) { @content; }
}
}What CSS will be generated by this Sass code?
.box {
width: 100%;
@include respond-to(medium) {
width: 50%;
}
}SASS
@mixin respond-to($breakpoint) { @if $breakpoint == small { @media (max-width: 600px) { @content; } } @else if $breakpoint == medium { @media (min-width: 601px) and (max-width: 1024px) { @content; } } @else if $breakpoint == large { @media (min-width: 1025px) { @content; } } } .box { width: 100%; @include respond-to(medium) { width: 50%; } }
Attempts:
2 left
💡 Hint
Look at which media query matches the 'medium' breakpoint in the mixin.
✗ Incorrect
The mixin wraps the content inside a media query for the 'medium' breakpoint, which is between 601px and 1024px. The base width is 100%, and inside that media query, width changes to 50%.
📝 Syntax
intermediate2:00remaining
Fix the syntax error in this breakpoint mixin call
Which option correctly fixes the syntax error in this Sass code?
@mixin breakpoint($size) {
@if $size == mobile {
@media (max-width: 480px) { @content; }
} @else if $size == tablet {
@media (min-width: 481px) and (max-width: 768px) { @content; }
}
}
.container {
@include breakpoint mobile {
padding: 1rem;
}
}SASS
@mixin breakpoint($size) { @if $size == mobile { @media (max-width: 480px) { @content; } } @else if $size == tablet { @media (min-width: 481px) and (max-width: 768px) { @content; } } } .container { @include breakpoint mobile { padding: 1rem; } }
Attempts:
2 left
💡 Hint
Mixin arguments must be enclosed in parentheses without quotes if they are identifiers.
✗ Incorrect
Sass mixin arguments require parentheses. Since 'mobile' is a variable-like identifier, it should be passed without quotes but inside parentheses.
❓ selector
advanced2:00remaining
Which selector is targeted inside this breakpoint mixin?
Consider this Sass code:
What CSS selector will have the color blue inside the media query?
@mixin respond($bp) {
@if $bp == desktop {
@media (min-width: 1024px) { @content; }
}
}
nav {
color: black;
@include respond(desktop) {
color: blue;
}
}What CSS selector will have the color blue inside the media query?
SASS
@mixin respond($bp) { @if $bp == desktop { @media (min-width: 1024px) { @content; } } } nav { color: black; @include respond(desktop) { color: blue; } }
Attempts:
2 left
💡 Hint
Look at the selector used before the mixin call.
✗ Incorrect
The mixin wraps the content inside a media query but does not change the selector. The selector remains 'nav'.
❓ layout
advanced2:00remaining
What layout change happens at this breakpoint?
Given this Sass code:
What will the grid layout look like on a screen 500px wide?
@mixin breakpoint($size) {
@if $size == mobile {
@media (max-width: 600px) { @content; }
}
}
.container {
display: grid;
grid-template-columns: repeat(4, 1fr);
@include breakpoint(mobile) {
grid-template-columns: 1fr;
}
}What will the grid layout look like on a screen 500px wide?
SASS
@mixin breakpoint($size) { @if $size == mobile { @media (max-width: 600px) { @content; } } } .container { display: grid; grid-template-columns: repeat(4, 1fr); @include breakpoint(mobile) { grid-template-columns: 1fr; } }
Attempts:
2 left
💡 Hint
Check the media query for max-width 600px and the grid-template-columns inside it.
✗ Incorrect
On screens 600px or less, the grid changes to one column (1fr), stacking items vertically. Otherwise, it uses four equal columns.
❓ accessibility
expert2:00remaining
Accessibility impact of breakpoint mixin usage
You use a breakpoint mixin to hide a navigation menu on small screens:
What is a potential accessibility issue with this approach?
@mixin hide-on-small {
@media (max-width: 600px) {
display: none;
}
}
nav {
@include hide-on-small;
}What is a potential accessibility issue with this approach?
SASS
@mixin hide-on-small { @media (max-width: 600px) { display: none; } } nav { @include hide-on-small; }
Attempts:
2 left
💡 Hint
Consider how display:none affects both visual and assistive technologies.
✗ Incorrect
display:none hides content visually and from screen readers, so keyboard and screen reader users cannot access the nav. Better approaches use aria attributes or off-screen positioning.