CSS minmax() Function

Definition and Usage

CSS minmax() The function is used for CSS grid layout and defines a size range that is greater than or equal to the minimum value and less than or equal to the maximum value.

Example

Using minmax() Define size ranges for grid columns:

.grid-container {
  display: grid;
  grid-template-columns: minmax(min-content, 350px) minmax(150px, 1fr) 120px;
  grid-gap: 5px;
  height: 150px;
  background-color: green;
  padding: 10px;
}

Try It Yourself

CSS Syntax

minmax(min, max)
Value Description
min

Required. Minimum value.

It can be one of the following: length, percentage, flex value (fr), or one of the following keywords:

  • auto
  • max-content
  • min-content
max

Required. Maximum value.

It can be one of the following: length, percentage, flex value (fr), or one of the following keywords:

  • auto
  • max-content
  • min-content

Technical Details

Version: CSS Grid Layout Module Level 2

Browser Support

The numbers in the table indicate the browser version that first fully supports this function.

Chrome Edge Firefox Safari Opera
59 16 52 10.1 44

Páginas relacionadas

Referencia:Función min() de CSS

Referencia:Función max() de CSS

Referencia:Atributo CSS grid-template-columns

Referencia:Atributo CSS grid-template-rows

Referencia:Atributo grid-auto-columns de CSS

Referencia:Atributo grid-auto-rows de CSS