Defining grids with flexible columns
grid-auto-columns

Use this property to define a grid system that has a flexible number of columns.
Property values
This property defines a column width for every element that is a direct descendant of a grid container when its width has not already been explicitly defined.
Specify this value using a percentage or a factional unit:
% | percentage | A percent of the grid container's width |
fr | fractional | A fractonal portion of the grid container's remaining available width (where the sum of all the fractional declarations equals the whole) |
Or use a fitting function:
min-content | The width of the element is the minimum amount necessary for any element in the grid column to have all its content fit without overflowing. |
max-content | The width of the element is the maximum amount necessary for any element in the grid column to have all its content fit without overflowing. |
minmax(H1, H2) | The width is not less than H1 and not more than H2 |
fit-content(H) | The width expands to whatever is needed to fit the contents of the element, but never more than H |
auto | Use whatever space is available after all other column constraints have been met |
Or use one of these font-relative units:
em | em | The font-size of the current font |
rem | relative em | The font-size of the <html> element |
ch | "0" | The advance measure (the width) of the current font's "0" glyph |
ic | ideograph count | The advance measure (the width) of the current font's "水" ideograph |
Or use these viewport-percentage units which account for different display device capabilities:
vh | viewport width | 1% of the viewport's width |
vw | viewport width | 1% of the viewport's width |
vi | viewport inline axis | 1% of the viewport's inline axis |
vb | viewport block axis | 1% of the viewport's block axis |
vmin | viewport minimum | Either vh or vw, whichever is smaller |
vmax | viewport maximum | Either vh or vw, whichever is larger |
Or use any of these fixed size units which are independent of the current font:
in | inch | A size equal 96px |
px | pixels | A size equal to 1/96 inch |
pt | point | A size equal 1in/72 = 1.33px |
pc | pica | A size equal 1in/6 = 12pt = 16px |
cm | centimeter | A size equal to 96px/2.54 = 37.8px |
mm | millimeter | A size equal to 96px/25.4 = 3.8px |
Q | quarter millimeter | A size equal to 96px/1016 = 0.94px |
Examples
/* new columns will each be at least 10% of the grid container's width,
but never more than 50% of the viewport's width */
grid-auto-columns: minmax(10%, 50vw);