CSS Grid Generator

Build a CSS grid layout visually: columns, rows, gaps and responsive auto-fit, with HTML and CSS to copy.

FreeNo sign-upPrivate — runs in your browser
CSS

  
HTML

How to use the CSS Grid Generator

  1. Choose a column layoutEqual columns, a responsive auto-fit grid that wraps on phones, a sidebar layout, or your own column sizes.
  2. Adjust rows and gapsSet row height, gaps and how many items to preview.
  3. Copy the codeCopy the CSS and the HTML, then replace the numbered boxes with your own content.

Example

3 equal columns, 100 px rows and 16 px gaps gives grid-template-columns: repeat(3, 1fr); gap: 16px;

Responsive cards: repeat(auto-fit, minmax(200px, 1fr)) shows as many 200 px+ columns as fit, and one column on a phone, with no media queries.

Frequently asked questions

What does 1fr mean?

One fraction of the free space. 1fr 2fr 1fr makes the middle column twice as wide as the others, after gaps are taken out.

What is the difference between auto-fit and auto-fill?

Both create as many columns as fit. auto-fit stretches the items to fill the row when there are only a few, while auto-fill keeps empty column tracks.

Grid or Flexbox?

Use Grid for two-dimensional layouts (rows and columns at once, like a page or a card gallery) and Flexbox for one row or column of items, like a navigation bar.

Popular posts from this blog

Character Counter

Speech to Text Online

Keyboard Tester