Module 06 of 11

Flexbox

Lessons

About This Module

For years, laying out a row of items or centering something both horizontally and vertically took awkward workarounds. Flexbox solved this with a layout model designed for arranging items along a single line — a row or a column — with simple control over spacing, alignment, and how items share the available room. It is now the default tool for navbars, toolbars, card rows, and countless small layout jobs.

This module starts with a beginner tutorial on flex containers and flex items, then focuses on the idea that makes everything click: the main axis and cross axis, and how justify-content and align-items position items along each. It continues with the sizing properties flex-grow, flex-shrink, and flex-basis, which decide how items expand and contract, and finishes with wrapping and gap for layouts that need more than one line.

Watch the lessons in order, then continue on to CSS Grid.

Lessons

4 videos
01

CSS Flexbox Tutorial for Beginners

An introduction to using Flexbox to lay out page elements, starting from the idea that Flexbox is a one-dimensional layout model.

02

CSS Flexbox: justify-content vs. align-items

The difference between the two key alignment properties: justify-content positions items along the main axis, while align-items positions them along the cross axis.

03

How Does flex-grow, flex-shrink and flex-basis Work?

Explains the powerful properties that control the size of flex container children, and clears up why they can be confusing at first.

04

gap and wrap CSS Properties in Flexbox

Shows how the gap and wrap properties work in a flex layout, plus a small trick to make the result look better.