0
0
SASSmarkup~20 mins

Grid system mixin from scratch in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Grid Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding the purpose of a grid system mixin
What is the main benefit of using a grid system mixin in Sass when building layouts?
AIt helps create reusable, consistent layout structures with customizable columns and gutters.
BIt allows you to write repetitive CSS code for each grid item manually.
CIt automatically generates JavaScript to control grid behavior on the page.
DIt replaces the need for any CSS media queries in responsive design.
Attempts:
2 left
💡 Hint
Think about how mixins help avoid repeating code and keep layouts consistent.
📝 Syntax
intermediate
2:00remaining
Sass mixin syntax for grid columns
Which of the following Sass mixin definitions correctly accepts two parameters: $columns and $gutter, and sets the width and margin-right accordingly?
A@mixin grid($columns, $gutter) { width: calc(100% / $columns - $gutter); margin-right: $gutter; }
B@mixin grid($columns, $gutter) { width: calc((100% / #{$columns}) - #{$gutter}); margin-right: $gutter; }
C@mixin grid($columns, $gutter) { width: calc(100% / $columns) - $gutter; margin-right: $gutter; }
D@mixin grid($columns, $gutter) { width: 100% / $columns - $gutter; margin-right: $gutter; }
Attempts:
2 left
💡 Hint
Remember to use interpolation inside calc() for Sass variables.
rendering
advanced
2:00remaining
Visual output of grid mixin with gutter
Given this Sass mixin and usage, what will be the width and margin-right of the .item element in the compiled CSS?
SASS
@mixin grid($columns, $gutter) {
  width: calc((100% / #{$columns}) - #{$gutter});
  margin-right: $gutter;
}

.item {
  @include grid(4, 1rem);
}
A.item { width: calc(25% - 1rem); margin-right: 1rem; }
B.item { width: 25% - 1rem; margin-right: 1rem; }
C.item { width: calc((100% / 4) - 1rem); margin-right: 1rem; }
D.item { width: calc(100% / 4 - 1rem); margin-right: 1rem; }
Attempts:
2 left
💡 Hint
Look carefully at how Sass outputs variables inside calc() with interpolation.
selector
advanced
1:30remaining
Selecting last grid item to remove margin
In a grid layout using a mixin that adds margin-right to each item, which CSS selector correctly targets every 4th item to remove its margin-right?
A.item:nth-child(4n) { margin-right: 0; }
B.item:nth-of-type(4) { margin-right: 0; }
C.item:last-child { margin-right: 0; }
D.item:nth-child(4) { margin-right: 0; }
Attempts:
2 left
💡 Hint
Think about how to select every 4th element, not just the 4th or last one.
accessibility
expert
2:00remaining
Ensuring accessible grid layout with ARIA roles
When building a grid layout with a custom Sass mixin, which ARIA role should you add to the container to best communicate the grid structure to screen readers?
Arole="list"
Brole="presentation"
Crole="table"
Drole="grid"
Attempts:
2 left
💡 Hint
Consider ARIA roles that describe a grid of items, not just a list or table.