CSS grid-auto-flow property
Example
Insert grid items column by column:
.grid-container
{
display:
grid
;
grid-auto-flow:
column
;
}
Try it »
Browser support
The numbers in the table indicate the first browser version that supports this property.
| property | |||||
|---|---|---|---|---|---|
| grid-auto-flow | 57 | 16 | 52 | 10 | 44 |
Property definition and usage
The grid-auto-flow property specifies how the auto-placement algorithm works, precisely controlling how auto-placed items are arranged in the grid.
| Default value: | auto |
|---|---|
| Inherited: | no |
| Animatable: | support. Read about animatable Try it |
| Version: | CSS Grid Layout Module Level 1 |
| JavaScript syntax: | object.style.gridAutoFlow="row dense" Try it |
Syntax
grid-auto-flow: row|column|dense|row dense|column dense;
| Value | Description |
|---|---|
| * row * | Default value. Places grid items by filling each row, adding new columns when necessary. |
| column | Places grid items by filling each column, adding new columns when necessary. |
| dense | This keyword specifies that the auto-placement algorithm uses a "dense" packing algorithm; if smaller items appear later, it tries to fill holes left earlier in the grid. This fills gaps left by larger items, but may also cause the original order to be disrupted. |
| row dense | Fill holes left earlier in the grid by row |
| column dense | Fill holes left earlier in the grid by column |
Example
Fill holes left earlier in the grid by row:
.grid-container
{
display:
grid
;
grid-auto-flow:
row
dense
;
}
Try it »
Related Articles
CSS Tutorial: CSS Grid Layout