grid: auto-flow / 1fr 1fr 1fr;
grid: auto-flow dense / 40px 40px 1fr;
grid: repeat(3, 80px) / auto-flow;
<section class="default-example" id="default-example">
<div class="example-container">
<div class="transition-all" id="example-element">
<div>One</div>
<div>Two</div>
<div>Three</div>
</div>
</div>
</section>
#example-element {
border: 1px solid #c5c5c5;
display: grid;
grid-gap: 10px;
width: 200px;
}
#example-element :nth-child(1) {
background-color: rgb(0 0 255 / 0.2);
border: 3px solid blue;
}
#example-element :nth-child(2) {
background-color: rgb(255 0 200 / 0.2);
border: 3px solid rebeccapurple;
grid-column: auto / span 3;
grid-row: auto / span 2;
}
#example-element :nth-child(3) {
background-color: rgb(94 255 0 / 0.2);
border: 3px solid green;
grid-column: auto / span 2;
}
Note: The sub-properties you don't specify are set to their initial value, as normal for shorthands. Also, the gutter properties are NOT reset by this shorthand.
Constituent propertiesThis property is a shorthand for the following CSS properties:
grid-auto-columns
grid-auto-flow
grid-auto-rows
grid-template-areas
grid-template-columns
grid-template-rows
/* <'grid-template'> values */
grid: none;
grid: "a" 100px "b" 1fr;
grid: [line-name1] "a" 100px [line-name2];
grid: "a" 200px "b" min-content;
grid: "a" minmax(100px, max-content) "b" 20%;
grid: 100px / 200px;
grid: minmax(400px, min-content) / repeat(auto-fill, 50px);
/* <'grid-template-rows'> /
[ auto-flow && dense? ] <'grid-auto-columns'>? values */
grid: 200px / auto-flow;
grid: 30% / auto-flow dense;
grid: repeat(3, [line1 line2 line3] 200px) / auto-flow 300px;
grid: [line1] minmax(20em, max-content) / auto-flow dense 40%;
/* [ auto-flow && dense? ] <'grid-auto-rows'>? /
<'grid-template-columns'> values */
grid: auto-flow / 200px;
grid: auto-flow dense / 30%;
grid: auto-flow 300px / repeat(3, [line1 line2 line3] 200px);
grid: auto-flow dense 40% / [line1] minmax(20em, max-content);
/* Global values */
grid: inherit;
grid: initial;
grid: revert;
grid: revert-layer;
grid: unset;
Values
<'grid-template'>
Defines the grid-template
including grid-template-columns
, grid-template-rows
and grid-template-areas
.
<'grid-template-rows'> / [ auto-flow && dense? ] <'grid-auto-columns'>?
Sets up an auto-flow by setting the row tracks explicitly via the grid-template-rows
property (and the grid-template-columns
property to none
) and specifying how to auto-repeat the column tracks via grid-auto-columns
(and setting grid-auto-rows
to auto
). grid-auto-flow
is also set to column
accordingly, with dense
if it's specified.
All other grid
sub-properties are reset to their initial values.
[ auto-flow && dense? ] <'grid-auto-rows'>? / <'grid-template-columns'>
Sets up an auto-flow by setting the column tracks explicitly via the grid-template-columns
property (and the grid-template-rows
property to none
) and specifying how to auto-repeat the row tracks via grid-auto-rows
(and setting grid-auto-columns
to auto
). grid-auto-flow
is also set to row
accordingly, with dense
if it's specified.
All other grid
sub-properties are reset to their initial values.
grid-template-rows
: none
grid-template-columns
: none
grid-template-areas
: none
grid-auto-rows
: auto
grid-auto-columns
: auto
grid-auto-flow
: row
grid-column-gap
: 0
grid-row-gap
: 0
column-gap
: normal
row-gap
: normal
grid-template-rows
: refer to corresponding dimension of the content areagrid-template-columns
: refer to corresponding dimension of the content areagrid-auto-rows
: refer to corresponding dimension of the content areagrid-auto-columns
: refer to corresponding dimension of the content areagrid-template-rows
: as specified, but with relative lengths converted into absolute lengthsgrid-template-columns
: as specified, but with relative lengths converted into absolute lengthsgrid-template-areas
: as specifiedgrid-auto-rows
: the percentage as specified or the absolute lengthgrid-auto-columns
: the percentage as specified or the absolute lengthgrid-auto-flow
: as specifiedgrid-column-gap
: the percentage as specified or the absolute lengthgrid-row-gap
: the percentage as specified or the absolute lengthcolumn-gap
: as specified, with <length>s made absolute, and normal computing to zero except on multi-column elementsrow-gap
: as specified, with <length>s made absolute, and normal computing to zero except on multi-column elementsgrid-template-rows
: simple list of length, percentage, or calc, provided the only differences are in the values of the length, percentage, or calc components in the listgrid-template-columns
: simple list of length, percentage, or calc, provided the only differences are in the values of the length, percentage, or calc components in the listgrid-template-areas
: discretegrid-auto-rows
: by computed value typegrid-auto-columns
: by computed value typegrid-auto-flow
: discretegrid-column-gap
: a lengthgrid-row-gap
: a lengthcolumn-gap
: a length, percentage or calc();row-gap
: a length, percentage or calc();grid =Examples Creating a grid layout HTML
<'grid-template'> |
<'grid-template-rows'> / [ auto-flow && dense? ] <'grid-auto-columns'>? |
[ auto-flow && dense? ] <'grid-auto-rows'>? / <'grid-template-columns'><grid-template> =
none |
[ <'grid-template-rows'> / <'grid-template-columns'> ] |
[ <line-names>? <string> <track-size>? <line-names>? ]+ [ / <explicit-track-list> ]?<grid-template-rows> =
none |
<track-list> |
<auto-track-list> |
subgrid <line-name-list>?<grid-auto-columns> =
<track-size>+<grid-auto-rows> =
<track-size>+<grid-template-columns> =
none |
<track-list> |
<auto-track-list> |
subgrid <line-name-list>?<line-names> =
'[' <custom-ident>* ']'<track-size> =
<track-breadth> |
minmax( <inflexible-breadth> , <track-breadth> ) |
fit-content( <length-percentage [0,â]> )<explicit-track-list> =
[ <line-names>? <track-size> ]+ <line-names>?<track-list> =
[ <line-names>? [ <track-size> | <track-repeat> ] ]+ <line-names>?<auto-track-list> =
[ <line-names>? [ <fixed-size> | <fixed-repeat> ] ]* <line-names>? <auto-repeat> [ <line-names>? [ <fixed-size> | <fixed-repeat> ] ]* <line-names>?<line-name-list> =
[ <line-names> | <name-repeat> ]+<track-breadth> =
<length-percentage [0,â]> |
<flex [0,â]> |
min-content |
max-content |
auto<inflexible-breadth> =
<length-percentage [0,â]> |
min-content |
max-content |
auto<length-percentage> =
<length> |
<percentage><track-repeat> =
repeat( [ <integer [1,â]> ] , [ <line-names>? <track-size> ]+ <line-names>? )<fixed-size> =
<fixed-breadth> |
minmax( <fixed-breadth> , <track-breadth> ) |
minmax( <inflexible-breadth> , <fixed-breadth> )<fixed-repeat> =
repeat( [ <integer [1,â]> ] , [ <line-names>? <fixed-size> ]+ <line-names>? )<auto-repeat> =
repeat( [ auto-fill | auto-fit ] , [ <line-names>? <fixed-size> ]+ <line-names>? )<name-repeat> =
repeat( [ <integer [1,â]> | auto-fill ] , <line-names>+ )<fixed-breadth> =
<length-percentage [0,â]>
<div id="container">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
CSS
#container {
display: grid;
grid: repeat(2, 60px) / auto-flow 80px;
}
#container > div {
background-color: #8ca0ff;
width: 50px;
height: 50px;
}
Result Specifications Browser compatibility
Loadingâ¦
See alsogrid-template
grid-template-rows
grid-template-columns
grid-template-areas
grid-auto-columns
grid-auto-rows
grid-auto-flow
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.5