×

css · level 2 · unit 1 · lesson 1

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

turns a flex row into a column.

Flexbox lines children up in a row unless you say otherwise. flex-direction: column stacks them from top to bottom instead, and keeps every other flex power, like gap.

The direction the children line up in is the . The direction at right angles to it is the . In a row the main axis runs across; in a column it runs downwards.

justify-content always works along the main axis and align-items along the cross axis. So in a column, justify-content moves things up and down, and align-items moves them across.

<div class="panel">
  <h2>Join the club</h2>
  <p>We meet every Friday.</p>
  <a href="https://example.com/join">Join now</a>
</div>
.panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background-color: honeydew;
}

Press show my page to see it here.

Change column to row and the three children line up side by side again.