Design responsive grid layouts with visual controls.
Visual CSS grid builder for rows, columns, gaps, and alignment. Customize grid-template and copy CSS instantly.
.grid-container {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr;
gap: 16px;
justify-items: stretch;
align-items: stretch;
justify-content: stretch;
align-content: stretch;
}CSS Grid is a two-dimensional layout system built into the browser. Unlike Flexbox (one-dimensional), Grid lets you define rows and columns at once with grid-template-columns and grid-template-rows. You place items into cells, control spacing with gap, and align content with justify-items, align-items, justify-content, and align-content. Grid is ideal for dashboard layouts, card grids, and page structures where you need explicit control over both axes.
Apply display: grid to a container. Define the track structure: grid-template-columns: 1fr 1fr 1fr creates three equal columns; 1fr is one fraction of the available space. Use gap (or row-gap, column-gap) for spacing. Child elements flow into the grid automatically by row, unless you assign grid-column and grid-row for explicit placement.
Grid is two-dimensional (rows + columns); Flexbox is one-dimensional (row or column). Use Grid when you need to align items in both directions, such as dashboard panels or card galleries. Use Flexbox for navbars, button groups, or single-row/column layouts. Both can be nested: a Grid cell can contain a Flex container. Pair Grid with tools like the Spacing Scale Assistant for consistent gap values, or the Border Radius Generator and Box Shadow Generator for styling grid cards.
| Aspect | CSS Grid | Flexbox |
|---|---|---|
| Dimensions | 2D (rows + columns) | 1D (row or column) |
| Best for | Page layout, dashboards, galleries | Navbars, button groups, alignment |
| Content-driven | No, structure is explicit | Yes, wraps based on content |
| Overlap / placement | Easy with grid-column/row | Harder, requires tricks |
Common patterns include: equal columns (1fr 1fr 1fr or repeat(3, 1fr)), sidebar layouts (250px 1fr), and responsive galleries using repeat(auto-fit, minmax(200px, 1fr)). For cards or dashboard widgets, combine Grid with consistent gaps and alignment options. Use grid-template-areas when you need named regions for cleaner markup.
Use media queries to change grid-template-columns at breakpoints: e.g. 1fr on mobile, 1fr 1fr at 768px, 1fr 1fr 1fr at 1024px. Alternatively, repeat(auto-fit, minmax(200px, 1fr)) creates a fluid grid that adds or removes columns based on container width, without media queries.
repeat(n, 1fr) creates n equal tracks. minmax(min, max) sets a minimum and maximum size for a track: minmax(200px, 1fr) means at least 200px, up to one fraction of remaining space. auto-fit fills the row with as many tracks as fit; empty tracks collapse. auto-fill behaves similarly but reserves space for empty tracks. Use auto-fit when you want items to grow into empty space; use auto-fill when you want consistent track sizing.
Defining only grid-template-columns without rows can create implicit rows that behave unexpectedly. Using fr with fixed tracks (200px 1fr 1fr) is fine, but mixing fr and % can cause overflow. Forgetting gap leaves items flush; use consistent spacing. Overusing nested grids when a single grid with grid-column spans would suffice increases complexity.
Design responsive grid layouts with visual controls.
Free CSS Grid generator — define rows, columns, and named grid areas visually and copy the generated CSS grid-template code. Perfect for responsive web layouts. No signup required.
Set inputs, grid cells, blend layers, or favicon source.
Check live output against your target layout or device.
Copy CSS, classes, or download icon files.
Advertisement
Named areas let you assign elements to regions like header, sidebar, and main with readable ASCII maps.
Copy the base template and adjust columns with media queries in your own stylesheet.
Grid templates are built locally; layout definitions are not sent to a server.
Verify output in production browsers and design tooling.
For design and prototyping—not a substitute for production asset pipelines.
Part of Design & UI Tools
More free tools for the same workflow.
Advertisement
Reviewed by EverydayTools Editorial Team on 2026-05-19.