CSS grid-auto-flow Property

❮ Previous Reference Next ❯

Example

.example1 {
  grid-auto-flow: column;
}

.example2 {
  grid-auto-flow: row;
}





1
2
Hello World!
3
4

Meaning

The grid-auto-flow property controls how the auto-placement algorithm works, specifying exactly how auto-placed items get flowed into the grid.

Default value:row
Inherited:No
Animatable:Yes
Version:CSS Grid Layout Module Level 1
JavaScript syntax:
object.style.gridAutoFlow="row|column|dense|row dense|column dense|initial|inherite|revert|revert-layer|unset";



Standard Syntax

grid-auto-flow: row|column|dense|row dense|column dense|initial|inherite|revert|revert-layer|unset;



Browser Support

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




Status







Property Values

The following table describes the values of this property.

Value Description
row This is default value. Specifies that the items Places by filling each row.
column Specifies that the items places by filling each column.
dense Specifies that the items place to fill any holes in the grid.
row dense Specifies that the items places by filling each row, and fill any holes in the grid.
column dense Specifies that the items places by filling each column, and fill any holes in the grid.
initial Sets this property to its default value.
inherit If specified, the associated element takes the computed value of its parent element animation-delay property.
revert Reverts the cascaded value of the property from its current value to the value the property
revert-layer Rollback styles to the ones specified in previous cascade layers.
unset Resets a property to its inherited value if the property naturally inherits from its parent, and to its initial value if not.



Default CSS Property Values

selectors {
  grid-auto-flow: row;
}



More Example



1
2
3
4
5
6

Example

.grid-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  grid-auto-flow: row;
}

.item3 {
  grid-column:span 3;
  grid-row:span 3;
}
❮ Previous Reference Next ❯