CSS Flexbox Guide
The display: flex property enables a flexible context for all its direct children. It is a one-dimensional layout method for laying out items in rows or columns.
The Container
To start using Flexbox, you must select a parent element and apply display: flex. This establishes a new flex formatting context.
The Axes
Flexbox deals with two axes: the Main Axis and the Cross Axis.
- Main Axis: Defined by
flex-direction. By default, it is horizontal (row). Aligned viajustify-content. - Cross Axis: Perpendicular to the main axis. By default, it is vertical. Aligned via
align-items.
Alignment
Using justify-content: center will center items along the main axis, while align-items: center will center them along the cross axis.
