grid max-content code example

Example 1: css grid make all rows same height

grid-auto-rows: 1fr;

Example 2: grid template columns

/* Keyword value */
grid-template-columns: none;

/* <track-list> values */
grid-template-columns: 100px 1fr;
grid-template-columns: [linename] 100px;
grid-template-columns: [linename1] 100px [linename2 linename3];
grid-template-columns: minmax(100px, 1fr);
grid-template-columns: fit-content(40%);
grid-template-columns: repeat(3, 200px);
grid-template-columns: subgrid;

/* <auto-track-list> values */
grid-template-columns: 200px repeat(auto-fill, 100px) 300px;
grid-template-columns: minmax(100px, max-content)
                       repeat(auto-fill, 200px) 20%;
grid-template-columns: [linename1] 100px [linename2]
                       repeat(auto-fit, [linename3 linename4] 300px)
                       100px;
grid-template-columns: [linename1 linename2] 100px
                       repeat(auto-fit, [linename1] 300px) [linename3];

/* Global values */
grid-template-columns: inherit;
grid-template-columns: initial;
grid-template-columns: unset;

Example 3: grid css fr width of content

/* Valeurs avec un mot-clé */
grid-auto-columns: min-content;
grid-auto-columns: max-content;
grid-auto-columns: auto;

/* Valeurs de longueur */
/* Type <length>       */
grid-auto-columns: 100px;
grid-auto-columns: 20cm;
grid-auto-columns: 50vmax;

/* Valeurs proportionnelles */
/* Type <percentage>        */
grid-auto-columns: 10%;
grid-auto-columns: 33.3%;

/* Valeurs <flex> */
grid-auto-columns: 0.5fr;
grid-auto-columns: 3fr;

/* Valeurs minmax() */
grid-auto-columns: minmax(100px, auto);
grid-auto-columns: minmax(max-content, 2fr);
grid-auto-columns: minmax(20%, 80vmax);

/* Valeurs fit-content() */
grid-auto-columns: fit-content(400px);
grid-auto-columns: fit-content(5cm);
grid-auto-columns: fit-content(20%);

/* Gestion de plusieurs pistes */
grid-auto-columns: min-content max-content auto;
grid-auto-columns: 100px 150px 390px;
​​​​​​​grid-auto-columns: 10% 33.3%;
grid-auto-columns: 0.5fr 3fr 1fr;
​​​​​​​grid-auto-columns: minmax(100px, auto) minmax(max-content, 2fr) minmax(20%, 80vmax);
grid-auto-columns: 100px minmax(100px, auto) 10% 0.5fr fit-content(400px);

/* Valeurs globales */
grid-auto-columns: inherit;
grid-auto-columns: initial;
grid-auto-columns: unset;

Tags:

Css Example