CSS Grid — Concept Check
Questions on CSS Grid. Two-dimensional layout: you define rows and columns, and place items into them. It handles page structure and card grids that flexbox can only approximate.
Questions in this quiz
8 questions on CSS Grid — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A developer uses `grid-template-columns: 1fr 2fr;` in a layout. What does this imply about the column widths?
- AThe columns will adjust based on content size.
- BBoth columns will be of equal width.
- CThe first column is twice as wide as the second.
- DThe first column takes one-third of the free space, the second two-thirds.
2.Why might `grid-template-columns: 1fr 1fr 1fr;` cause overflow when a gap is added?
- AThe sum of the fractions exceeds available space.
- BEach column becomes 33.33%, leaving no space for gaps.
- CGaps automatically reduce column width.
- DGaps are not considered in the free space calculation.
3.A layout uses `grid-template-areas` to define regions. What is a key advantage of this approach?
- AIt allows for easy visual reordering without DOM changes.
- BIt automatically adjusts grid size based on content.
- CIt eliminates the need for media queries entirely.
- DIt enforces strict alignment only in one direction.
4.Using `repeat(auto-fit, minmax(min(16rem, 100%), 1fr))`, what happens on a narrow viewport?
- AColumns will disappear if they can't fit.
- BColumns will overflow the viewport.
- CColumns will each be at least 16rem or fit the viewport.
- DColumns will shrink below 16rem.
5.What is the effect of `grid-auto-flow: dense;` in a grid layout?
- AIt prevents any gaps in the grid layout.
- BIt forces all items to align to the start.
- CIt backfills gaps left by spanning items.
- DIt makes all items span across the grid.
6.A developer uses `auto-fill` instead of `auto-fit`. What is the practical difference?
- ABoth behave identically in all scenarios.
- B`auto-fit` collapses empty tracks, `auto-fill` does not.
- C`auto-fill` collapses empty tracks, `auto-fit` does not.
- D`auto-fill` stretches items, `auto-fit` does not.
7.Why might `grid-template-rows: subgrid;` be used in a child grid?
- ATo make child items responsive without media queries.
- BTo allow child items to span multiple columns.
- CTo automatically fill all available space.
- DTo ensure child items align with the parent's tracks.
8.What does `place-items: center;` achieve in a grid container?
- AAligns items only horizontally.
- BCenters all items within their grid areas.
- CAligns the entire grid within its container.
- DAligns items only vertically.