CSS Grid Generator
The ultimate visual CSS Grid architect. Design complex layouts, paint grid areas, manage track sizing, and generate production-ready code instantly.
About
CSS Grid Layout is the most powerful layout system available in CSS. It allows for two-dimensional layouts to be created on the web. However, the syntax, particularly for grid-template-areas and complex track sizing, can be error-prone and difficult to visualize mentally. A single typo in a grid area string can break the entire structure.
This tool transforms the abstract coding process into a visual drafting experience. It is designed for developers who need to prototype robust, responsive interfaces without wrestling with syntax errors. By strictly separating the visual design from the code generation, we ensure that the resulting CSS is valid, optimized, and ready for production environments. This is particularly critical for large-scale applications where layout stability is paramount.
The visual editor supports advanced features including named grid areas, explicit track sizing using pixels, percentages, or fraction units fr, and gap management. The logic handles the mathematical distribution of space, ensuring that minmax() functions and auto flows behave as expected across different viewports.
Formulas
When using the fraction unit fr, the browser calculates the available space after subtracting fixed sizes and gaps. The formula for a single fr unit is:
If the grid content is smaller than the grid container, alignment properties determine the position. For minmax(min, max), the track will never be smaller than min and never larger than max. If max is smaller than min, then max is ignored and the track is sized as min.
Reference Data
| Property | Values | Applies To | Description |
|---|---|---|---|
| display | grid, inline-grid | Container | Defines the element as a grid container and establishes a new grid formatting context. |
| grid-template-columns | 200px, 1fr, repeat() | Container | Defines the line names and track sizing functions of the grid columns. |
| grid-template-rows | auto, minmax() | Container | Defines the line names and track sizing functions of the grid rows. |
| grid-template-areas | "header header" | Container | Specifies named grid areas. Cells not covered by an area are denoted by a dot (.). |
| column-gap | 10px, 1em | Container | Sets the size of the gap (gutter) between columns. |
| row-gap | 10px, 1em | Container | Sets the size of the gap (gutter) between rows. |
| justify-items | start, end, center, stretch | Container | Aligns grid items along the inline (row) axis (default is stretch). |
| align-items | start, end, center, stretch | Container | Aligns grid items along the block (column) axis (default is stretch). |
| justify-content | space-between, center | Container | Aligns the grid as a whole within the container (inline axis). |
| align-content | space-between, center | Container | Aligns the grid as a whole within the container (block axis). |
| grid-column | 1 / 3, span 2 | Item | Shorthand for grid-column-start and grid-column-end. |
| grid-row | 1 / 3, span 2 | Item | Shorthand for grid-row-start and grid-row-end. |
| grid-area | header, 1/1/2/2 | Item | Assigns an item to a named area or defines start/end lines for both axes. |
| justify-self | start, end, center, stretch | Item | Aligns a grid item inside a single cell along the inline axis. |
| align-self | start, end, center, stretch | Item | Aligns a grid item inside a single cell along the block axis. |