0
0
SASSmarkup~20 mins

Breakpoint variables and maps in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Breakpoint Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding breakpoint maps in Sass
Given the following Sass map for breakpoints, what is the value of $breakpoints["tablet"]?
SASS
$breakpoints: (
  "mobile": 320px,
  "tablet": 768px,
  "desktop": 1024px
);
A768px
B320px
C1024px
Dnull
Attempts:
2 left
💡 Hint
Look at the key named "tablet" in the map.
📝 Syntax
intermediate
2:00remaining
Correct syntax for defining breakpoint variables
Which of the following Sass code snippets correctly defines a map named $breakpoints with keys "small" and "large" and values 480px and 1200px respectively?
A$breakpoints = (small: 480px, large: 1200px);
B$breakpoints: ["small" => 480px, "large" => 1200px];
C$breakpoints: ("small": 480px, "large": 1200px);
D$breakpoints: {"small": 480px, "large": 1200px};
Attempts:
2 left
💡 Hint
Sass maps use parentheses and colons for key-value pairs.
selector
advanced
2:00remaining
Using breakpoint maps in media queries
Given the breakpoint map below, which Sass code correctly applies styles only for screens wider than the "desktop" breakpoint?
SASS
$breakpoints: (
  "mobile": 320px,
  "tablet": 768px,
  "desktop": 1024px
);
A@media (min-width: $breakpoints["desktop"]) { .container { width: 100%; } }
B@media (min-width: map-get($breakpoints, "desktop")) { .container { width: 100%; } }
C@media (min-width: $breakpoints.desktop) { .container { width: 100%; } }
D@media (min-width: map-get($breakpoints.desktop)) { .container { width: 100%; } }
Attempts:
2 left
💡 Hint
Use the Sass function to get values from maps.
layout
advanced
2:00remaining
Responsive layout with breakpoint variables
You want a container to have 100% width on mobile and tablet, but max-width 1200px on desktop and larger. Which Sass code using breakpoint variables achieves this?
SASS
$breakpoints: (
  "mobile": 320px,
  "tablet": 768px,
  "desktop": 1024px
);
A.container { width: 100%; @media (max-width: map-get($breakpoints, "desktop")) { max-width: 1200px; } }
B.container { max-width: 1200px; @media (max-width: map-get($breakpoints, "tablet")) { width: 100%; } }
C.container { width: 100%; max-width: 1200px; }
D.container { width: 100%; @media (min-width: map-get($breakpoints, "desktop")) { max-width: 1200px; } }
Attempts:
2 left
💡 Hint
Use min-width media query for desktop and larger.
accessibility
expert
3:00remaining
Ensuring accessible font scaling with breakpoint maps
You have a Sass map of breakpoints and want to scale font sizes responsively for accessibility. Which approach below correctly uses breakpoint maps and relative units to improve accessibility?
SASS
$breakpoints: (
  "mobile": 320px,
  "tablet": 768px,
  "desktop": 1024px
);
Abody { font-size: 1rem; @media (min-width: map-get($breakpoints, "tablet")) { font-size: 1.125rem; } @media (min-width: map-get($breakpoints, "desktop")) { font-size: 1.25rem; } }
Bbody { font-size: 16px; @media (min-width: map-get($breakpoints, "tablet")) { font-size: 18px; } @media (min-width: map-get($breakpoints, "desktop")) { font-size: 20px; } }
Cbody { font-size: 1em; @media (min-width: map-get($breakpoints, "desktop")) { font-size: 2em; } }
Dbody { font-size: 100%; @media (max-width: map-get($breakpoints, "tablet")) { font-size: 90%; } }
Attempts:
2 left
💡 Hint
Use relative units like rem for better accessibility.