CSS Grid Generator
Create CSS Grid layouts visually. Define columns, rows, and gaps to generate the grid code.
Grid Settings
Preview
1
2
3
4
5
6
7
8
9
CSS Code
display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 10px;
CSS Grid Generator
Build complex two-dimensional layouts with our CSS Grid Generator. CSS Grid Layout is the most powerful layout system available in CSS. It is a 2-dimensional system, meaning it can handle both columns and rows, unlike Flexbox which is largely 1-dimensional.
This tool provides a simple interface to define the basic structure of a grid container, including the number of columns, rows, and the gap between them.
Key Concepts
- Grid Container: The element on which
display: gridis applied. - Grid Template Columns: Defines the number and size of the columns. We use
repeat()and1fr(fractional unit) for equal sizing in this generator. - Grid Template Rows: Defines the number and size of the rows.
- Gap: Sets the size of the gap (gutter) between rows and columns.
How to Use
- Set the number of columns you want.
- Set the number of rows.
- Adjust the gap size to separate the cells.
- The preview shows exactly how the grid will look.
- Copy the CSS code to implement this grid in your project.
When to use Grid vs Flexbox?
Use Grid when you need to control the layout by both columns and rows (2D). Use Flexbox when you only need to control the layout by row OR column (1D). They work great together!