Responsive Grid Width

Web layout

How Responsive Grid Width works

Calculate equal-width grid tracks and how many minimum-width columns fit inside a fixed-width container.

Find usable content width

Subtract left and right padding from the outer width. Borders and scrollbar space are not included; account for those in the input.

Subtract gaps before division

For n columns, there are n−1 internal gaps. Divide the remaining width by n to calculate equal track width. A fixed grid may be unable to fit at the chosen container width.

Find responsive capacity

For minimum width m and gap g, the maximum whole number of columns is floor((content width + g)/(m+g)). This is a geometric model; actual CSS Grid may handle auto-fit, min-content, intrinsic item widths or subpixel rendering differently.

Worked example

A 1,200 px container with 24 px padding on both sides and three 16 px gaps has 1,104 px for four equal tracks, or 276 px per column. Four 260 px minimum columns fit.

Try the calculator

About the method

This tool uses the stated arithmetic and assumptions. Test the worked example and confirm the inputs before using the result.