CSS Flexbox Layout
Master flexible box layouts for responsive design
Introduction to Flexbox
Flexbox is a one-dimensional layout method for arranging items in rows or columns. Items flex (expand) to fill additional space or shrink to fit into smaller spaces.
This simple property transforms all direct children into flex items.
Flex Direction
The flex-direction
property establishes the main axis, defining the direction flex items are placed in the flex container.
Row (Default)
Row Reverse
Column
Column Reverse
Flex Wrap
The flex-wrap
property controls whether the flex container is single-line or multi-line, and the direction of the cross-axis.
No Wrap (Default)
Wrap
Justify Content
The justify-content
property aligns flex items along the main axis of the current line of the flex container.
Flex Start (Default)
Flex End
Center
Space Between
Space Around
Practical Example: Navbar
A common use case for flexbox is creating navigation bars.
Flex Grow
The flex-grow
property specifies how much a flex item will grow relative to the rest of the flex items.
Responsive Flexbox
Flexbox can be combined with media queries to create responsive layouts. Resize your browser to see the effect.