CSS Topics
CSS Module

CSS Flexbox Layout

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.

Status: Coming Soon

We are crafting this tutorial

Our team is working on interactive diagrams, code challenges, and exercises for CSS Flexbox Layout. Check back soon for the full guide!

What You'll Learn

  • 1Enabling the Flexible Box layout model using display: flex
  • 2Switching dimensions: flex-direction row, row-reverse, column, column-reverse
  • 3Distributing content along the main axis using justify-content alignments
  • 4Aligning child items along the cross axis using align-items and align-self
  • 5Handling content wrap thresholds: flex-wrap, flex-grow, flex-shrink, and gap properties
sandbox.css
.flex-parent {
  display: flex;
  flex-direction: row;       /* Arrange items in a row */
  justify-content: space-between; /* Space items evenly */
  align-items: center;       /* Align items vertically */
  gap: 12px;                  /* Spacing between items */
  flex-wrap: wrap;           /* Wrap items to next line if needed */
}

.flex-child {
  flex: 1;                   /* Grow & shrink equally */
}
Interactive playground coming soon