Challenge - 5 Problems
Grid Column Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate1:30remaining
What is the output CSS of this SASS loop?
Given the following SASS code, what CSS rule will be generated for
.col-3?SASS
@for $i from 1 through 4 { .col-#{$i} { grid-column: span $i; } }
Attempts:
2 left
💡 Hint
Look at how the loop variable $i is used inside the selector and property.
✗ Incorrect
The loop runs from 1 to 4, creating classes .col-1 to .col-4. For .col-3, the grid-column property is set to 'span 3'.
🧠 Conceptual
intermediate1:00remaining
How many CSS classes are generated by this SASS code?
Consider this SASS code snippet:
How many CSS classes will be generated?
@for $col from 1 through 6 {
.grid-col-#{$col} {
grid-column: span $col;
}
}How many CSS classes will be generated?
Attempts:
2 left
💡 Hint
The loop runs from 1 through 6 inclusive.
✗ Incorrect
The loop runs from 1 to 6, so it generates 6 classes: .grid-col-1 to .grid-col-6.
❓ selector
advanced2:00remaining
Which option correctly generates grid columns with a gap using SASS loops?
You want to create grid column classes with a gap of 1rem between columns. Which SASS code snippet correctly applies the gap only between columns, not after the last column?
Attempts:
2 left
💡 Hint
Think about how to remove margin from the last column only.
✗ Incorrect
Option D applies margin-right: 1rem to .col-#{$i}:not(:last-child) for each i, ensuring the gap only between columns and no margin after the last column regardless of its class.
❓ rendering
advanced1:30remaining
What visual layout results from this CSS grid with generated columns?
Given this CSS generated by SASS:
If you place three divs with classes
.col-1 { grid-column: span 1; }
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.grid-container {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 1rem;
}If you place three divs with classes
col-1, col-2, and col-3 inside .grid-container, how will they be arranged?Attempts:
2 left
💡 Hint
Remember the container has 4 equal columns and spans add up to more than 4.
✗ Incorrect
The container has 4 columns. The first div spans 1 column, second spans 2 columns (total 3), the third spans 3 columns which doesn't fit in remaining 1 column space, so it wraps to next row.
❓ accessibility
expert2:30remaining
Which approach improves accessibility when generating grid columns with SASS loops?
You generate grid column classes with SASS loops for a responsive layout. Which option best improves accessibility for keyboard users and screen readers?
Attempts:
2 left
💡 Hint
Think about semantic meaning and meaningful labels for assistive technologies.
✗ Incorrect
Using semantic HTML and meaningful ARIA labels helps screen readers understand content. Adding tabindex to all items can cause confusing tab stops. Roles should match actual grid semantics only if appropriate.