Flexibility Without Limits
Flexbox (Flexible Box Layout) is a one-dimensional layout method. " One-dimensional " means Flexbox works with only one axis at a time: either horizontally or vertically.
Key Roles:
- Flex Container: The element inside which " centering magic " is enabled.
- Flex Items: Those we align. Important: flex properties affect only direct children.
Main and Cross Axes — The Foundation
This is the most important concept. Imagine two strings stretched inside the container.
- Main Axis: Elements are arranged along it.
- Cross Axis: Perpendicular to the main axis.
Important
Most Flexbox properties control exactly the position of elements on these axes. If you understand where the main axis is now, you understand how centering will work.