Logo

Complete Tools

Search tools
Ctrl K
Favoritekofi

CSS Grid Generator

Generate CSS Grid layouts with real-time visual preview.

Generate CSS grid code with real-time visual preview. Control columns, rows, gaps, and alignment. Perfect for responsive layouts. Copy CSS code instantly.

Categories
CSS Tools
Grid Structure
Columns: 3
Rows: 2
Gap Settings
Column Gap: 16px
Row Gap: 16px
Gap Unit
Alignment
Justify Items
Align Items
1
2
3
4
5
6
Grid Container Preview (3x2)
CSS Grid Code
display: grid;grid-template-columns: repeat(3, 1fr);grid-template-rows: repeat(2, 1fr);column-gap: 16px;row-gap: 16px;justify-items: stretch;align-items: stretch;

What is CSS Grid Generator?

CSS Grid Generator is a free online tool that helps you create two-dimensional grid layouts using CSS Grid. Perfect for building complex page layouts, card grids, and responsive designs with precise control over rows, columns, and gaps.

With our grid generator, you can:

  • Set grid structure - configure columns and rows (1-6 each)
  • Adjust gaps - control spacing between grid items (px or rem)
  • Align items - justify and align grid items
  • Preview in real-time with numbered grid cells
  • Copy instantly with ready-to-use CSS code

Understanding CSS Grid

CSS Grid Layout is a two-dimensional layout system for the web. It lets you lay content out in rows and columns, making it perfect for page layouts.

Basic Grid Syntax

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

Key Features

Full Grid Control

  • Columns: 1-6
  • Rows: 1-6
  • Column Gap: 0-50px or 0-5rem
  • Row Gap: 0-50px or 0-5rem
  • Justify Items: start, end, center, stretch
  • Align Items: start, end, center, stretch

Visual Real-Time Preview

See your grid layout with numbered cells showing the structure.

Responsive Design Ready

Perfect for creating layouts that adapt to different screen sizes.

Dark Theme Support

Works seamlessly in both light and dark modes.

How to Use

  1. Set Grid Structure: Adjust columns and rows sliders
  2. Configure Gaps: Set column and row gaps, choose unit (px/rem)
  3. Align Items: Select justify-items and align-items
  4. Preview: See real-time grid layout
  5. Copy CSS: Click Copy button

Common Use Cases

Page Layout

.layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  grid-template-rows: auto 1fr auto;
  gap: 1rem;
}

Card Grid

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

Responsive Grid

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

Browser Compatibility

  • Chrome: Version 57 and above - Full support
  • Firefox: Version 52 and above - Full support
  • Safari: Version 10.1 and above - Full support
  • Edge: Version 16 and above - Full support
  • Opera: Version 44 and above - Full support

Frequently Asked Questions

When should I use Grid vs Flexbox?

Use Grid for two-dimensional layouts (rows AND columns). Use Flexbox for one-dimensional layouts (row OR column).

What does 1fr mean?

1fr means one fraction of available space. repeat(3, 1fr) creates 3 equal-width columns.

How do I create responsive grids?

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

What's the difference between gap and margin?

gap creates space between grid items only. margin adds space around all sides of elements.

Can I nest grids?

Yes! Grid items can also be grid containers, allowing complex nested layouts.

Comments

Complete Tools
AboutTermsPrivacyContact

Copyright © 2022 - 2025 Complete Tools. Unless otherwise noted, all code MIT license.


Made with by Complete JavaScript