How can I create grid columns that have a minimum width of 200px and a maximum width of 300px? Currently, when using the code
grid-template-columns: repeat(auto-fit, minmax(200px, 300px));
, the columns always render at 300px.
To make columns shrink proportionally, I tried using:
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
However, this caused the columns to become too large. After reviewing the documentation for minmax(), I couldn't find a suitable example to address this issue.
Is there a workaround solution available for this problem? See The Fiddle for reference.
The Answer
An important aspect of resolving this issue is modifying the code to: minmax(300px, auto));
and adding box-sizing: border-box;
.
Failure to include these adjustments may result in the grid not being properly centered when collapsing into one column layout. Thank you!