The main axis is defined by flex-direction, which has four possible values:
row
row-reverse
column
column-reverse
The two row settings will create the main axis horizontally - or inline direction. The two column settings will create the main axis vertically - or block direction. block or inline here refer to the CSS display settings which we have covered previously.
The axis determines the flow of your content - you can think of this as being either rows or columns - and they will be determined when you start aligning and justifying content within a flex container.
Moving the HTML code for the elements themselves to reorder
Appending -reverse to row or column will reverse the order in the specified row or column
Using the order property of the individual items inside the grid
There are three ways to explicitly set the order in which items will appear in a grid.
Ordering Elements Demo
flex-direction:row; will lay elements out from left to right. But flex-direction:row-reverse will flip that order and display elements from right to left.
Aligning Items & Justifying Content with Flexbox
To align items on the cross axis use align-items with the possible values:
stretch
flex-start
flex-end
center
To justify content on the main axis use justify-content, which has the possible values:
flex-start
flex-end
center
space-around
space-between
space-evenly
Aligning & Justifying in Action
By setting different values for the properties align-items and justify-content you can easily create elegant distribution of elements across the available space. The align-items property will align the items on the cross axis.