CSS Grid Generator
Visually design complex CSS Grid layouts. Define your rows, columns, and gaps with ease and get production-ready CSS instantly.
display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 10px 10px;
About the CSS Grid Generator
Set the number of columns and rows and the gap between them, and copy the CSS Grid code for a card grid, gallery or dashboard.
Everything you enter is processed in your browser; nothing is uploaded or stored.
How to use it
- Set the columns and rows.
- Set the row and column gap.
- Copy the CSS snippet onto your container element.
How CSS Grid is set up
display: grid turns a container into a grid. grid-template-columns: repeat(3, 1fr) makes three equal columns – fr means a fraction of the free space – and gap sets the space between cells without margins.
Children fill the cells in order. For a grid that adapts to the screen without media queries, use grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)).
Example
A three-column product grid with 16 px gaps: display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;.
Frequently asked questions
What does 1fr mean?
One fraction of the remaining space; three 1fr columns share the width equally.
How do I make a responsive grid?
Use repeat(auto-fill, minmax(min-size, 1fr)) so columns wrap as the screen narrows.
How do I make one item span two columns?
Give it grid-column: span 2.