How to use the CSS Grid Generator
- Set the column and row templates, or switch on responsive auto-fit.
- Adjust gaps and alignment, and click an item to make it span.
- Copy the CSS.
What does this tool do?
CSS grid handles rows and columns at the same time, which makes it the right tool for page layouts, galleries and dashboards. repeat(auto-fit, minmax(200px, 1fr)) creates a responsive grid that adds columns as space allows — no media queries needed.
Why use it?
- Auto-fit responsive grids.
- Spanning items.
- Live preview.
Use cases
- Page layouts with header, sidebar, content and footer.
- Photo galleries and product listings.
- Dashboards with widgets that span several columns.
A responsive card grid in one line
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; }
On a phone this shows one column, on a tablet two or three, and on a wide screen as many as fit.
Common mistakes
- Using fixed pixel columns that overflow on small screens — combine minmax() with fr units.
- Confusing auto-fit and auto-fill: auto-fit stretches items to fill space, auto-fill keeps empty tracks.
- Nesting grids or flexbox when one grid with spanning items would do.
Privacy
Everything you type is processed in your browser. Nothing you enter is sent to our servers or stored by us. There's no account to create and nothing to install.
Frequently asked questions
What is an fr unit?
A fraction of the free space. 1fr 2fr gives the second column twice the space of the first.
Grid or flexbox?
Grid for two-dimensional layouts (rows and columns together), flexbox for laying items out in one direction.
How do I make an item span columns?
Use grid-column: span 2; on the item, or set a start and end line like grid-column: 1 / 3.
Content last updated . See how M2Toolkit works.