Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The minmax() function in CSS grid is used to define a size range for grid tracks (rows and columns). The first parameter of the function defines the minimum size and the second parameter defines the maximum size.

When the maximum width is set to 100%, it means that the track can grow up to the full width of its container, but not more. This is useful for creating responsive designs where the size of the grid tracks adjusts according to the size of the viewport.

For example, the following code creates a grid with two columns where the first column has a minimum width of 200px and a maximum width of 1fr (to take up all available space), and the second column has a minimum width of 100px and a maximum width of 100% (to prevent it from expanding beyond the width of its container):

.grid {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(100px, 100%);
}