Visual CSS Grid Builder

Turn a layout idea into clean CSS Grid code. Start with cards, a sidebar, a gallery or a dashboard, then tune the columns and individual items for three screen sizes.

Free · no account · layout generation runs in your browser.

Build a layout that adapts

Start with a layout, select an item, then adjust each screen size.

Grid settings

Editing desktop rules (1024 px and up)

Item alignment

Selected item

Spans and starts apply to this screen size. Order and item count apply to all sizes. Fixed positions can override the visible effect of reordering.

Responsive preview

Live CSS

1100 CSS px · desktop rules

The frame runs your generated media queries. Wide previews scale to fit this workspace; controls remain full size. Item colors and outlines are examples, outside the exported layout CSS.

Mobile: below 768 px · Tablet: 768–1023 px · Desktop: 1024 px and up. Change the width to test a boundary.

Take the code

.layout-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  grid-auto-rows: minmax(100px, auto);
  gap: 16px;
}

@media (min-width: 768px) {
  .layout-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }
}

@media (min-width: 1024px) {
  .layout-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
  }
}

Layout rules only. Add your content, typography and component styling. The downloaded HTML includes the CSS and works as a standalone example.

Complete the layout with fluid type from CSS Clamp / Fluid Typography Generator and a spacing system from WordPress Spacing System Generator. For a block theme, also explore WordPress theme.json Generator.

How to build a responsive CSS Grid layout

  1. Choose a starter layout. Each preset applies real settings for mobile, tablet and desktop.
  2. Choose a screen size, or enter a preview viewport width. The active rules change at 768 and 1024 CSS pixels, exactly as they do in the generated media queries.
  3. Set columns, row sizing and gaps. Use equal columns or the two-column 1:3 sidebar. Content-sized rows grow when your real content needs more space.
  4. Select an item in the preview or the item list. Change its span and start position for this screen size. Zero means automatic placement. Add, remove or reorder items in the shared HTML source.
  5. Check the other screen sizes, then copy the CSS and HTML. Download the combined HTML example to try it locally.

From a card grid to a small dashboard

A responsive card collection

Start with Card grid: one column on mobile, two on tablet and three on desktop. Set gaps for each size and let the rows grow with descriptions of different lengths.

A feature card with supporting stories

Feature + cards gives the first desktop card two columns and two rows. On tablet it spans both columns; on mobile it returns to one. Edit each screen size without forcing a desktop span into a single-column layout.

A sidebar that stacks on mobile

Sidebar + content uses a 1:3 track ratio on wider screens and a single column below 768 px. Replace the example items with navigation and article content, preserving a sensible reading order.

Use CSS Grid with WordPress and Gutenberg

WordPress has native Grid layout controls for supported blocks, including Group. For a simple equal-card layout, try those controls first. The generator's custom item starts, spans, row sizing and breakpoint rules can require custom CSS beyond the editor's native settings.

For custom CSS, add layout-grid in the container block's Additional CSS class(es) field. Add the matching layout-item-1, layout-item-2 and other generated item classes to its direct child blocks. Put the CSS in the site's available custom CSS area or your theme stylesheet. Check the rendered markup: extra wrappers or theme rules may require selector adjustments.

For theme or template integration, adapt the HTML example to your actual content and enqueue the stylesheet through the theme's normal process. theme.json manages many theme settings and styles, but this download is not a theme.json layout export or a WordPress plugin. Test changes in a staging environment first.

Keep meaningful source order for keyboard and screen-reader users. Visual placement can move a card without changing its reading order.

Frequently asked questions

Does the code switch layouts automatically?

Yes. Mobile rules are the base CSS, tablet overrides start at 768 px, and desktop overrides start at 1024 px. Preview buttons change the frame's real viewport width; the same generated media queries choose its layout. These are viewport queries, not container queries.

Why did changing the column count reset my fixed starts?

Changing columns clamps spans to the new grid and returns start rows and columns to automatic placement for that screen size. This avoids pushing an existing card outside the new columns. Set new fixed starts afterward if needed.

Can I overlap cards or drag them freely?

The editor uses explicit numeric starts and spans rather than freeform dragging. It rejects overlapping placements when both cards have fixed rows and columns. Automatic placement follows normal CSS Grid rules; empty cells can remain after large spans. The code does not use dense packing that could further change visual reading order.

Why does my page look different from the colored preview?

The generated CSS contains layout rules. Preview colors, borders, padding and selection outlines are example styling. Your font, content, wrappers and other styles determine the final appearance. Fixed rows may overflow with long content; choose content-sized rows when cards need to grow.

Can I save this as a reusable project?

The current layout is kept only in page memory. Copy the code or download the HTML before leaving. This version does not import CSS, store projects, export themes or create nested grids.