Set columns, rows, gaps, and track sizes. Click and drag on the preview to place spanning grid items. Copy the complete CSS.
No items placed yet. Drag on the grid →
CSS Grid Generator is an interactive visual builder for CSS Grid layouts. Configure the number of columns and rows (up to 12 × 8), set uniform or custom track sizes using any valid CSS unit (fr, px, auto, minmax()), and control column and row gaps independently.
The live preview renders your exact grid using real CSS — what you see is literally the code you get. Click and drag across cells in the preview to place a grid item that spans those rows and columns. Each item is assigned a distinct colour and appears in the items list on the left where you can remove individual items or clear them all.
The generated CSS output includes the container rule (.grid-container) and a separate rule for each placed item (.item-1, .item-2, etc.) with grid-column and grid-row span values ready to copy.
1fr, 200px, auto, minmax(100px, 1fr). Leave on default for equal 1fr tracks.gap shorthand; otherwise it uses row-gap col-gap.col×row) are shown in each cell to guide placement.CSS Grid is a two-dimensional layout system. Setting display: grid on a container turns its direct children into grid items. The key properties:
grid-template-columns — defines the width of each column track. repeat(3, 1fr) creates three equal columns, each taking one third of available space. Mix units: 200px 1fr 1fr — a fixed sidebar and two flexible columns.grid-template-rows — same concept for row heights. Without an explicit height on the container, fr rows are sized to content. Set a fixed container height to make fr rows divide available vertical space.gap (formerly grid-gap) — shorthand for row-gap and column-gap. One value: equal gaps. Two values: row-gap column-gap.grid-column: 1 / 3 — places a child starting at column line 1 and ending at line 3 (spans 2 columns). Line numbers start at 1. -1 refers to the last line.grid-row: 1 / 2 — places a child in row track 1 (between lines 1 and 2).fr unit — "fractional unit." Distributes remaining space proportionally. After fixed/auto tracks consume their space, fr tracks share what's left.Children without explicit placement auto-flow into the next available cell — you don't need to specify positions for every item, only for those that span multiple tracks.
Let us know what's wrong with CSS Grid Generator.
Thank you — report received!