Interactive Demo
Overview
Control how flex items are aligned within a flex container. Use justify-content for horizontal alignment and align-items for vertical alignment.Justify Content
Control horizontal alignment of flex items.| Class | Alignment | CSS | Usage |
|---|---|---|---|
.justify-start | Start | justify-content: flex-start; | Align to start |
.justify-center | Center | justify-content: center; | Center alignment |
.justify-end | End | justify-content: flex-end; | Align to end |
.justify-between | Space between | justify-content: space-between; | Space between items |
.justify-around | Space around | justify-content: space-around; | Space around items |
.justify-evenly | Space evenly | justify-content: space-evenly; | Equal space around items |
Align Items
Control vertical alignment of flex items.| Class | Alignment | CSS | Usage |
|---|---|---|---|
.items-start | Start | align-items: start; | Align to start |
.items-center | Center | align-items: center; | Center alignment |
.items-end | End | align-items: end; | Align to end |
.items-stretch | Stretch | align-items: stretch; | Stretch to fill |
Align Self
Control individual item alignment.| Class | Alignment | CSS | Usage |
|---|---|---|---|
.self-center | Center | align-self: center; | Center this item |
.self-start | Start | align-self: start; | Align to start |
.self-end | End | align-self: end; | Align to end |
Align Content
Control how multiple lines of flex items are aligned when there’s extra space in the cross axis.| Class | Alignment | CSS | Usage |
|---|---|---|---|
.content-start | Start | align-content: start; | Align lines to start |
.content-center | Center | align-content: center; | Center lines |
.content-end | End | align-content: end; | Align lines to end |
.content-between | Space between | align-content: space-between; | Space between lines |
.content-around | Space around | align-content: space-around; | Space around lines |
.content-evenly | Space evenly | align-content: space-evenly; | Equal space around lines |
Order
Control the order of flex items.| Class | Value | CSS | Usage |
|---|---|---|---|
.order-first | First | order: -99999; | Move item to first position |
.order-last | Last | order: 99999; | Move item to last position |
Flex Grow & Shrink
Control how flex items grow and shrink.| Class | Property | CSS | Usage |
|---|---|---|---|
.flex-grow | Grow | flex-grow: 1; | Allow item to grow |
.flex-shrink | Shrink | flex-shrink: 1; | Allow item to shrink |
Examples
Centered Content
Header with Space Between
Vertical Center
Individual Item Alignment
Space Around and Evenly
Order Control
Flex Grow
Common Patterns
Navigation Bar
Card with Icon
Best Practices
- Center content: Use
items-center justify-centerfor centered layouts - Space between: Use
justify-betweenfor header navigation - Vertical alignment: Use
items-centerto vertically center items in a row - Individual control: Use
self-*utilities to override container alignment

