Loading...

Which way did they go?

Once you've set flex or inline-flex onto an element, it becomes a "flex container", and therefore, all children elements inside it are now "flex items". Many properties are placed on the flex container to dictate what the flex items will do.

Flex items will all run along the same axis on one line. So if you have three flex items, they will run horizontally in a row, or vertically in a column. The property flex-direction dictates which way the flex items will run.

<style>
.container1 {
display:flex;
flex-direction:row;
}
.container2 {
display:flex;
flex-direction:column;
}
</style>

<div class="container1">
<div class="flex-item">Item 1</div>
<div class="flex-item">Item 2</div>
<div class="flex-item">Item 3</div>
</div>
<div class="container2">
<div class="flex-item">Item 1</div>
<div class="flex-item">Item 2</div>
<div class="flex-item">Item 3</div>
</div>

Item 1
Item 2
Item 3
Item 1
Item 2
Item 3

Value Effect
row flows horizontally (default)
row-reverse horizontal, but in the reverse direction of "row"
column flows vertically from top to bottom
column-reverse flows vertically from bottom to top