CSS Grid Container — exercises and bug fixes
10 hands-on exercises and 10 find-the-bug challenges for the CSS Grid Container lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(10)
- 1
Build a 3-column gallery
easy15 minMake .gallery a grid container with exactly three equal columns, using grid-template-columns: repeat(3, 1fr).
- Set .gallery to display: grid.
- Use grid-template-columns: repeat(3, 1fr) for three equal columns.
- 2
Add breathing room with gap
easy15 minThis grid's tiles are touching. Add a 16px gap between both rows and columns.
- 3
Build a responsive card grid
easy15 minMake .responsive-grid automatically fit as many 200px-minimum columns as space allows, using grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)).
- 4
Set explicit row heights
easy15 minGive .layout two rows of exactly 80px each, using grid-template-rows: 80px 80px.
- 5
Center items inside grid cells
easy15 minCenter every .icon-grid item, both horizontally and vertically, within its own cell using place-items: center.
- Center items vertically (align-items: center).
- Center items horizontally (justify-items: center).
- 6
Create a grid container
easy10 minMake #grid a grid container.
- 7
Use inline-grid
easy10 minMake #grid an inline grid container.
- 8
Add a gap
easy10 minGive the grid a 20px gap.
- 9
Flow items into columns
easy10 minSet grid-auto-flow to column.
- 10
Centre the items
medium10 minCentre every item on both axes.
Find the bug(10)
- 1
Fix the grid that isn't a grid
easy15 min.layout was meant to be a CSS grid, but display is set to block, so grid-template-columns has no effect. Fix the display value.
- 2
Fix the wrong column count
easy15 minThis gallery should show 3 columns, but it's only defined with 2. Fix grid-template-columns to create three equal columns.
- 3
Fix the missing gap
easy15 minThis board's cells are touching because gap is set to 0. Give it a 12px gap instead.
- 4
Fix the invalid fr unit
easy15 minThis grid's column sizes use a typo'd unit ("1f" instead of "1fr"), so the browser ignores it and falls back to a single column. Fix the unit.
- 5
Fix the misaligned badges
easy15 min.badge-grid's items should be centered in their cells, but align-items is set to stretch. Fix it to center.
- 6
Fix the missing display
easy8 minGrid properties do nothing without display: grid.
- 7
Fix flex used where grid was meant
easy8 minThis layout needs a grid container.
- 8
Fix the misspelled value
easy8 minThe value is inline-grid, not grid-inline.
- 9
Fix the flow property name
easy8 minThe property is grid-auto-flow.
- 10
Fix the grid set on the items
easy8 minThe container needs display: grid, not the cells.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace