Grid

Containers, column tracks, item placement, gaps, and alignment — everything needed to build any grid layout.

Containers container-{width}

container-960

container-1100

container-1200

container-1440

container-1920

Nested

container-800 inside container-1200

Equal Columns grid cols-{n}

grid cols-1 cols-md-2 cols-lg-4

1

2

3

4

grid cols-2

1

2

grid cols-3

1

2

3

Maximum responsive cols-1 cols-sm-2 cols-md-3 cols-lg-4 cols-xl-6 cols-xxl-4

1

2

3

4

5

6

Auto-Fit Columns cols-fit-{min}

As many columns of at least min width as fit — the browser recomputes on every resize, so no breakpoints are needed. Resize the window to watch the count change. min(…, 100%) keeps a lone column from overflowing narrow containers.

grid cols-fit-250 gap-16-32 — one class, every width correct

≥250px

≥250px

≥250px

≥250px

≥250px

≥250px

cols-fit vs cols-fill — two items in a wide row

fit: stretches

fit: stretches

fill: stays ~200px

fill: stays ~200px

auto-fit collapses the empty tracks so items grow into them; auto-fill keeps them, so items hold their minimum. It responds to the container, not just the viewport — the same class yields fewer columns inside a sidebar. Use cols-N when the design demands an exact count. Breakpoint variant: cols-fit-md-300.

Column Ratios cols-{ratio} (dots or colons)

Sidebar cols-1 cols-md-1.3

Sidebar (1fr)

Main (3fr)

Holy Grail cols-1 cols-md-1.3.1

Left (1fr)

Main (3fr)

Right (1fr)

Wide + Narrow cols-1 cols-md-2.1

Wide (2fr)

Narrow (1fr)

Colon spelling cols-1 cols-md-1:3 — same output as cols-md-1.3

Sidebar (1fr)

Main (3fr)

Gaps gap / gapx / gapy

Fixed gap-16

A

B

C

Fluid gap-8-40

A

B

C

Split gapx-32-48 gapy-4-8

A

B

C

D

Grid Alignment

align-center

Short

Tall column with more content to show vertical centering.

Short

justify-items-center

Centered

Centered

Centered

place-center

Both axes

Both axes

Both axes

Self Alignment

self-start

self-center

self-end

self-stretch

Justify Self

start

center

end

stretch

Order order-{n}

order reorders grid items in source-independent order. Same syntax as flex — order-1, order-md-2, etc. See also Flexbox → Order.

A (order-1)

B

C

D

Item Span span-{n} / rowspan-{n}

Applied to grid children. span-N makes an item occupy N column tracks; rowspan-N makes it span N rows. Positive integers only. Supports breakpoints: span-md-4, rowspan-lg-3.

span-2 on the first item (cols-3 parent)

span-2 (2 cols wide)

B

C

D

E

Dashboard: span-2 rowspan-2 feature card (cols-3)

Featured (span-2 rowspan-2)

B

C

D

E

Responsive: mobile stacks, md+ features a wide first item

full width / span-md-2

B

C

D

N-Track Grids cols-12 + span-N

Combine a many-track parent with span on children for Bootstrap-style layouts. cols-N accepts any positive integercols-7, cols-12, cols-14, even cols-100 all work. Children claim however many tracks they need via span-N.

2/12 + 10/12 split cols-12 span-2 span-10

2/12 sidebar

10/12 main

Thirds cols-12 span-4 span-4 span-4

4/12

4/12

4/12

Mixed widths cols-12 span-6 span-3 span-3

6/12

3/12

3/12

Responsive: stack mobile, 3/12 + 9/12 at md+

stacks mobile, 3/12 md+

stacks mobile, 9/12 md+

Non-12 tracks: cols-7 span-2 span-5 (any N works)

2/7

5/7

Ratios vs N-track + span

Two approaches produce identical visual output. Pick based on what changes at breakpoints:

Ratios (cols-1.3.1)

Best when proportions are fixed across the design. Parent declares the shape; children don't need any class.

cols-1 cols-md-1.3.1 = stack mobile, 1:3:1 md+

N-track + span (cols-12 + span-N)

Best when children need to reflow responsively or the design follows a strict 12-column grid discipline.

cols-12 span-md-3 span-lg-4 = narrow on md, wider on lg

GitHub