Intern Track Roadmap

CSS flexbox: alignment

This course introduces flexbox alignment with the main axis kept in its default left-to-right row. It starts with display: flex, the roles of flex container and flex items, and the main and cross axes. It then covers justify-content for the main axis and align-items for the cross axis, including the stretch default. Later lessons show centering in both directions, overriding one item with align-self, and spacing with gap. The last lesson builds a navbar and a centered overlay from small nested flex containers.

What you'll learn

  • ✓How display: flex turns direct children into flex items along a main and cross axis
  • ✓How justify-content distributes leftover space with flex-start, center and the space-* values
  • ✓How align-items positions items on the cross axis and why stretch is the default
  • ✓Centering content both ways with justify-content and align-items
  • ✓Overriding one item's alignment with align-self
  • ✓Spacing items with gap, row-gap and column-gap instead of margins
Free preview · Lesson 1 3 min read

From flow to flexbox: display: flex

The last course covered normal flow: block boxes stacking and inline boxes flowing with text. It's good at both jobs. But three very common layout requests have no clean answer in normal flow. "Put these three items in a row, evenly spaced." "Center this box horizontally and vertically." "Make…

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...