FC

⊞ CSS Grid Generator

Design grid layouts visually - columns, rows, gaps and copy CSS

1
2
3
4
5
6
.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  column-gap: 16px;
  row-gap: 16px;
}

How to Use the CSS Grid Generator

CSS Grid is the most powerful layout system in CSS - use it for two-dimensional page layouts, card grids, dashboard panels, and photo galleries. Adjust columns and rows with the sliders, then fine-tune the template values manually (e.g. type "200px 1fr 300px" for a three-column layout with fixed sidebars). Column/row gaps control the whitespace between cells. The live preview updates instantly. Copy the CSS and apply it to your container. Each child element automatically fills a grid cell.

Responsive card grid

grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));

3-column layout

grid-template-columns: 250px 1fr 250px;
When should I use CSS Grid versus Flexbox?

CSS Grid is for two-dimensional layouts — controlling both rows and columns simultaneously. Flexbox is for one-dimensional layouts — a single row or single column. Use Grid when: laying out the overall page structure (header, sidebar, main, footer), creating card grids, dashboard widgets, or any layout where items need to align on both axes. Use Flexbox when: distributing items in a navigation bar, centering elements, creating a single row of buttons, or handling flexible content that wraps to new lines. The most common pattern: Grid for the page macro layout, Flexbox for component micro layout.

What is the fr unit in CSS Grid?

fr (fractional unit) represents a fraction of the available free space in the grid container. display: grid; grid-template-columns: 1fr 2fr 1fr creates three columns — the middle takes twice as much space as each side column. They divide the container after any fixed sizes are subtracted. grid-template-columns: 200px 1fr allocates 200px to the first column, and all remaining space to the second. Multiple fr values divide proportionally: 1fr 1fr 1fr = three equal columns. fr is the most important CSS Grid unit to understand — it enables responsive column layouts without media queries.

What does grid-template-areas allow me to do?

grid-template-areas lets you name grid regions and place elements by name instead of by line numbers. Define the layout: grid-template-areas: 'header header' 'sidebar main' 'footer footer'. Then assign elements: header { grid-area: header; } main { grid-area: main; } sidebar { grid-area: sidebar; }. The layout can be redefined at breakpoints by reassigning the template-areas string. This is the most readable way to define complex layouts — the ASCII art area definition visually represents the actual page layout.

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

Both create as many columns as fit, but they differ when there is extra space. repeat(auto-fill, minmax(200px, 1fr)): creates as many 200px columns as fit, and if there is leftover space, it creates empty tracks. repeat(auto-fit, minmax(200px, 1fr)): creates only as many columns as there are items, and empty tracks collapse — the existing items grow to fill all space. For a card grid where you always want cards to fill the row: auto-fit. For a grid where you want consistent column counts regardless of item count: auto-fill.

How do I make a grid item span multiple columns or rows?

grid-column: span 2 makes an item span 2 columns. grid-column: 1 / 3 places the item from column line 1 to line 3 (spanning 2 columns). grid-row: span 2 spans 2 rows. grid-column: 1 / -1 spans from the first to the last line (full width). Negative line numbers count from the end. For a featured card in a grid that should span the full width: .featured { grid-column: 1 / -1; } — this works regardless of how many columns the grid has.

What is the difference between justify and align in Grid?

Justify controls the inline axis (horizontal by default). Align controls the block axis (vertical by default). justify-content distributes grid columns within the container. align-content distributes grid rows within the container. justify-items positions items within their cell horizontally. align-items positions items within their cell vertically. justify-self and align-self override per individual grid item. This is identical to Flexbox semantics — the same axis naming system. The mnemonic: justify = horizontal (like left-justified text), align = vertical.

What other layout tools are on this site?

The Flexbox Generator handles one-dimensional layouts that complement Grid structure. The Responsive Breakpoints tool provides standard viewport widths for grid breakpoint planning. The CSS Unit Converter handles the px-to-rem conversions common in gap and padding values. The Aspect Ratio Calculator helps maintain proportional card dimensions in grid layouts. The Box Shadow Generator styles individual grid cells and cards. All are in the Dev Tools CSS section.

Complete Guide

📊 Key Data Points

fr unit

Fractional unit — allocates remaining space proportionally between tracks

grid-template-areas

Named area syntax — the most readable way to define complex 2D layouts

auto-fill vs auto-fit

repeat(auto-fill, minmax(200px,1fr)) creates responsive columns without media queries

CSS Grid Generator — Visual 2D Layout Builder -- Complete USA Guide 2026

CSS Grid is the layout model for two-dimensional designs — rows AND columns simultaneously. grid-template-columns, grid-template-rows, grid-area, and fr units give unprecedented layout control, but the syntax is hard to visualize without a live preview.

This visual builder generates grid layouts with a live preview and complete CSS output. Runs in your browser.

**Long-tail searches answered here:** css grid generator visual with code output online free, grid-template-columns layout builder browser, css grid area layout generator no install.

For one-dimensional layouts, see Flexbox Generator.

🔬 How This Calculator Works

Builds grid-template-columns, grid-template-rows, gap, and optionally grid-template-areas definitions. The fr unit allocates fractional shares of remaining space — 1fr 2fr 1fr creates three columns where the middle is twice as wide as the others.

repeat() notation generates repeated track patterns: repeat(3, 1fr) creates three equal columns. minmax() sets size constraints: minmax(200px, 1fr) means each column is at least 200px but can grow.

The visual grid shows clickable cells. Drag to merge cells and generate grid-column and grid-row span values. The grid-template-areas syntax is generated automatically from the visual layout.

✅ What You Can Calculate

fr unit visualization

Toggle between 1fr 1fr 1fr (three equal columns) and 1fr 2fr 1fr (wider middle) and see the proportions live.

Visual area naming

Click and drag cells to name grid areas and generate the grid-template-areas ASCII map syntax — the most powerful and readable way to define complex layouts.

repeat() and minmax()

Toggle between explicit 200px 1fr 200px and repeat() notation. Configure minmax() constraints for responsive grids without media queries.

Auto-placement vs explicit placement

See the difference between auto-placement (items fill in reading order) and explicit grid-area placement (items placed in named areas).

🎯 Real Scenarios & Use Cases

Magazine-style page layouts

Multi-column, multi-row layouts with a header spanning all columns, a sidebar, main content, and footer. Build the named area layout here and export the CSS.

Photo gallery grids

grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)) creates a responsive gallery that fills the available width with same-sized cards.

Dashboard layouts

Analytics dashboards need different-sized widgets in a grid. Name areas and position items explicitly using the visual area builder.

Responsive card grids

Define each grid state here and export the CSS for each breakpoint.

💡 Pro Tips for Accurate Results

fr vs auto. 1fr takes a fractional share of remaining space. auto takes as much as content needs. In auto 1fr auto, the middle column takes all remaining space.

auto-fill vs auto-fit. repeat(auto-fill, minmax(200px,1fr)) fills the row with as many columns as fit. auto-fit collapses empty tracks.

grid-template-areas for readable layout. Named areas make CSS self-documenting: header header then sidebar main then footer footer immediately communicates the intended layout.

Subgrid for alignment across components. CSS Subgrid lets children align to parent grid tracks — use for card grids where footers need to align across cards.

🔗 Use These Together

🏁 Bottom Line

CSS Grid enables layouts previously requiring complex positioning hacks. The visual builder makes the two-dimensional nature concrete. For component layouts: Flexbox Generator. For responsive sizing: Responsive Breakpoints.