PUBLIC.INTERNET

Responsive Grid Calculator

Give it a container width, a number of columns, and a gutter size, and it works out how wide each column is once the gutters are subtracted. A strip of equal-width bars previews the grid, and the CSS box produces a ready-to-paste .container rule written for either CSS Grid or Flexbox, including a few column-span helper classes.

Visual Preview

Column Width

0px

Total Gutters

0px

Content Width

0px

CSS Code


      
    

How to calculate a grid

  1. Type a Container Width (px), the Number of Columns, and the Gutter Size (px). Results update as you type.
  2. Read Column Width, Total Gutters, and Content Width (the container minus all gutters) in the three cards.
  3. Choose CSS Grid or Flexbox under Layout System to change the generated code.
  4. Click Copy CSS to copy the .container rule along with its span helper classes.

The arithmetic behind the numbers

A grid with N columns has N minus 1 gutters between them, not N. Total gutter space is gutter times (N minus 1), and each column is the container width minus that total, divided by N. With the defaults of 1200 px, 12 columns, and 24 px gutters, that is 264 px of gutters and 78 px columns. The tool shows an error if the gutters alone fill the container.

The CSS Grid output does not hard-code widths. It uses repeat(N, 1fr) with a gap, and the browser does the same subtraction. One catch: 1fr has an automatic minimum, so a long URL or wide image can force its column wider than the rest, while minmax(0, 1fr) keeps them equal. The Flexbox output sizes each .column with calc((100% - total gutters) / N). Both versions set max-width, not a fixed width, so on a narrower viewport the real columns shrink below the number shown.