Changing Direction
When working with flexbox you need to think in terms of two axes — the main axis and the cross axis. The main axis is determined by the flex-direction property, and it determines the direction in which the elements will be laid out. The cross axis runs perpendicular to the main axis and is used to align the elements along this axis.
Knowing how to work with these two axes is essential to effectively using Flexbox. It will allow us to control the distribution of elements and create flexible and responsive layouts. Throughout this document, we will refer back to these axes, so it is important to have a solid understanding of them from the start.
The main axis is difined by flex-direction which has four possible values:
rowrow-reversecolumncolumn-reverse
1. row
By default, flex-direction is set to row, which means that the child elements will be positioned in a row, side by side.
2. column
However, if you change flex-direction to column, the child elements will be positioned in a column, one above the other.
3. row-reverse
The row-reverse and column-reverse values of the flex-direction property are similar to row and column, respectively, except that the items are laid out in the opposite direction. So, when using row-reverse, the items are arranged from right to left,
4. column-reverse
and when using column-reverse, the items are arranged from bottom to top. These values can be useful for creating different layouts and changing the visual order of the items within a flex container.
row and column are two of the main axis directions that can be used to align items in a flex container. The main difference between row and column is the direction in which the items are arranged, with row aligning items horizontally and column aligning items vertically.
It’s worth noting that there are also row-reverse and column-reverse options, which arrange items in the reverse order of row and column, respectively. However, for the purpose of simplicity, from now on, we will focus on explaining the row and column options.