Easy Tutorial
❮ Css3 Pr Text Emphasis Sel Lang ❯

CSS minmax() Function

CSS Functions

Example

Set the width and height range of elements:

#container {
    display: grid;
    grid-template-columns: minmax(max-content, 300px) minmax(200px, 1fr) 150px;
    grid-gap: 5px;
    box-sizing: border-box;
    height: 200px;
    width: 100%;
    background-color: #8cffa0;
    padding: 10px;
}

#container > div {
    background-color: #8ca0ff;
    padding: 5px;
}

Definition and Usage

The minmax() function defines a size range greater than or equal to min and less than or equal to max. It is used with CSS Grid Layout.

Supported Versions: CSS3


Browser Support

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

Function Chrome Edge Firefox Safari Opera
var() 57.0 16.0 76.0 10.1 44.0

CSS Syntax

/* <inflexible-breadth>, <track-breadth> values */
minmax(200px, 1fr)
minmax(400px, 50%)
minmax(30%, 300px)
minmax(100px, max-content)
minmax(min-content, 400px)
minmax(max-content, auto)
minmax(auto, 300px)
minmax(min-content, auto)

/* <fixed-breadth>, <track-breadth> values */
minmax(200px, 1fr)
minmax(30%, 300px)
minmax(400px, 50%)
minmax(50%, min-content)
minmax(300px, max-content)
minmax(200px, auto)

/* <inflexible-breadth>, <fixed-breadth> values */
minmax(400px, 50%)
minmax(30%, 300px)
minmax(min-content, 200px)
minmax(max-content, 200px)
minmax(auto, 300px)
Value Description
length A non-negative length.
percentage A non-negative percentage relative to the inline size of the grid container in column grid tracks, and the block size of the grid container in row grid tracks. If the size of the grid container depends on the size of its tracks, then percentage must be treated as auto. The user agent may adjust the intrinsic size contributions of the track to the size of the grid container and increase the final size of the track by the minimum amount that would result in honoring the percentage.
flex A non-negative dimension with the fr unit that specifies the flex factor of the grid track. Tracks sized with flex cause the track to become flexible and consume the remaining space proportional to their flex factor.
max-content Represents the largest maximal content contribution of the grid items occupying the grid track.
min-content Represents the largest minimal content contribution of the grid items occupying the grid track.
auto As a maximum, identical to max-content. As a minimum, represents the largest minimum size (as specified by min-width/min-height) of the grid items occupying the grid track.

CSS Functions

❮ Css3 Pr Text Emphasis Sel Lang ❯