Grid Layout Flashcards

(20 cards)

1
Q

What is CSS Grid Layout?

A

A two-dimensional layout system that lets you organize content into rows and columns simultaneously.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you create a grid container?

A

Set display: grid (or display: inline-grid) on the container element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a grid track?

A

The space between any two adjacent grid lines — essentially a row or a column.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you define column tracks?

A

Use grid-template-columns, e.g. grid-template-columns: 200px 1fr 1fr creates three columns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the fr unit?

A

A flexible fraction unit that represents a share of the available space in the grid container, e.g. 1fr 2fr gives the second column twice the space.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does repeat() do?

A

A shorthand for repeating track definitions, e.g. repeat(3, 1fr) creates three equal columns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between an explicit and implicit grid?

A

The explicit grid is defined by grid-template-rows/columns. Implicit tracks are auto-created when items are placed outside the explicit grid.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you size implicit grid tracks?

A

Use grid-auto-rows and grid-auto-columns, e.g. grid-auto-rows: 100px.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does minmax() do?

A

Defines a size range for a track, e.g. minmax(100px, auto) means at least 100px tall but can grow with content.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you place an item using line numbers?

A

Use grid-column-start/end and grid-row-start/end, e.g. grid-column: 1 / 3 spans from line 1 to line 3.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the grid-area property?

A

A shorthand that can set grid-row-start, grid-column-start, grid-row-end, and grid-column-end in one declaration, or reference a named grid area.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you create named grid areas?

A

Use grid-template-areas with strings representing the layout, e.g. “header header” “nav main” “nav footer”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the rules for grid-template-areas?

A

Every cell must be filled; repeat a name to span cells; use . for empty cells; areas must be rectangular; areas can’t appear in multiple disconnected locations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the gap property in grid?

A

Sets the gutter between rows and columns. Accepts one value (both) or two (row-gap column-gap).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How does auto-fill differ from auto-fit in repeat()?

A

auto-fill creates as many tracks as fit, even if empty. auto-fit collapses empty tracks to zero, letting filled tracks expand.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Can grid items overlap?

A

Yes — items can be placed in overlapping positions using explicit line-based placement, and z-index controls their stacking.

17
Q

What is a subgrid?

A

A nested grid that inherits track definitions from its parent grid, using display: grid and subgrid as a track value.

18
Q

How does grid layout differ from flexbox?

A

Grid is two-dimensional (rows and columns), while flexbox is one-dimensional (row or column). They can be used together.

19
Q

What does grid-auto-flow control?

A

How auto-placed items fill the grid — by row (default), column, or with dense packing to fill holes.

20
Q

Does visual reordering with grid affect accessibility?

A

Yes — screen readers and keyboard navigation follow DOM order, not visual order. Only use grid placement for visual reordering, not logical reordering.