The Flexible Box Layout Module (Flexbox) makes it easier to design flexible responsive layout structures without using float or positioning. It allows you to align items and distribute space within a container automatically.
1. The Flex Container Properties
To start using Flexbox, you must define a parent container with display: flex;.
Example A: Centering Content (Justify-Content: Center)
1
2
3
Example B: Space Between Items
Left
Middle
Right
Example C: Column Layout
Stack 1
Stack 2
Stack 3
3. Flex Item Properties
You can also control individual items inside the flex container:
flex-grow: Defines the ability for a flex item to grow if necessary.
order: Controls the order in which items appear.
align-self: Allows the default alignment to be overridden for individual items.
Key Advantage: Flexbox is "Direction-Agnostic." Unlike regular layouts (which are block/vertically and inline/horizontally based), flexbox works perfectly for any UI design regardless of screen orientation.