Flex container

Properties applied to the container define the direction, wrapping and positioning of child items

Flex direction

This defines the direction items are placed in within the flex container, essentially whether to extend in horizontal rows or vertical columns.

.container {
    display: flex;
    flex-direction: row [default] | row-reverse | column | column-reverse;
}

row

1
2
3

row-reverse

1
2
3

column

1
2
3

column-reverse

1
2
3

Flex wrap

By default flex items will try to fit onto one line. Wrapping can be controlled with this property and the flex-direction to control the axis of stacking

.container {
    display: flex;
    flex-wrap: nowrap [default] | wrap | wrap-reverse;
}

nowrap

1
2
3
4
5

wrap

1
2
3
4
5

wrap-reverse

1
2
3
4
5