cssgridgenerator
Marketing sections

CSS Grid Feature Section Generator

A section heading over a grid of feature cards that reflows from one column to three.

Open in
1040px

Drag across the grid to draw an area. Arrow keys nudge, Shift + arrows resize.

space to pan · ⌘scroll to zoom
11fr21fr31fr4
1auto2auto3
heading1 / 1 / 2 / 4
feature-12 / 1 / 3 / 2
feature-22 / 2 / 3 / 3
feature-32 / 3 / 3 / 4

Named areas. The CSS is a picture of the layout, and only the properties that actually change get repeated inside each media query.

.features {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto auto auto;
  gap: 20px;
  grid-template-areas:
    "heading"
    "feature-1"
    "feature-2"
    "feature-3";
}

.features > .heading { grid-area: heading; }
.features > .feature-1 { grid-area: feature-1; }
.features > .feature-2 { grid-area: feature-2; }
.features > .feature-3 { grid-area: feature-3; }

@media (min-width: 860px) {
  .features {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 28px;
    grid-template-areas:
      "heading   heading   heading"
      "feature-1 feature-2 feature-3";
  }
}

How this layout works

Feature sections almost always want auto-fit rather than fixed column counts: repeat(auto-fit, minmax(240px, 1fr)) gives three cards on a laptop, two on a tablet and one on a phone from a single declaration.

The difference between auto-fit and auto-fill shows up when there are fewer cards than columns. auto-fit collapses the empty tracks so the remaining cards stretch; auto-fill keeps them, leaving a gap where a fourth card would be. For a marketing row you almost always want auto-fit.

Equal-height cards come free — grid items stretch to their row by default. If a card has a button that must sit at the bottom regardless of copy length, make the card itself a grid with an auto 1fr auto row list.

Every property used here is listed in the CSS Grid cheat sheet, with the reason to reach for it.

Frequently asked questions

What is the difference between auto-fit and auto-fill?
They differ only when there are fewer items than columns. auto-fit collapses the empty tracks so the remaining cards stretch to fill the row; auto-fill keeps them, leaving a hole where another card would go. Marketing rows usually want auto-fit.
How do I make feature cards the same height?
They already are — grid items stretch to their row by default. If you need the button pinned to the bottom of each card regardless of copy length, make the card itself a grid with grid-template-rows: auto 1fr auto.
How do I center a grid in CSS?
Use justify-content: center on the grid container to centre the whole grid inside it, and margin-inline: auto with a max-width to centre the container in the page. These are different jobs: the first moves the tracks within the container, the second moves the container itself.
How do I center items inside a CSS grid?
Set place-items: center on the container. That is shorthand for align-items plus justify-items, and it centres every item inside its own cell on both axes. For a single item, use place-self: center on that item instead.
How do I make a CSS grid responsive?
Use grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) and it reflows at every width with no media queries at all. Add breakpoints only when the exact column count matters, or when the layout has to change shape rather than just wrap.
When should I use CSS Grid instead of Flexbox?
Use Grid when things must line up in two directions at once, and Flexbox when content flows along one axis. A page skeleton or dashboard is Grid; a navbar or row of buttons is Flexbox. They nest: Grid for the page, Flexbox inside the cells.

How to use it

  1. Open the pattern

    The feature grid loads into the editor already responsive, with every breakpoint set up.

  2. Change the tracks

    Edit the column and row sizes in the Tracks panel. Anything valid in a track list works.

  3. Redraw at another width

    Move the ruler past a breakpoint marker and rearrange. Only the placement changes.

  4. Copy the code

    Take CSS, HTML, Tailwind or a shadcn component. The media queries are already written.

More in Marketing sections

Elsewhere in the library

Browse all 46 layout patterns →