×

css · level 2 · unit 2 · lesson 2

  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

Flex children to the full height of the row.

Unless told otherwise, flex children stretch along the cross axis. In a row, every child grows as tall as the tallest one. That is why cards in a flex row come out the same height.

Often that is what you want. When it is not, align-items: flex-start lines the children up at the top, flex-end at the bottom and center halfway.

lines them up by their text instead. The baseline is the invisible line letters sit on, so a big title and small words read as one line.

<div class="row">
  <div class="card">Short</div>
  <div class="card">A much longer card, with lots and lots of words that wrap onto several lines</div>
</div>
.row {
  display: flex;
  gap: 12px;
}
.card {
  padding: 12px;
  background-color: lightyellow;
}

Press show my page to see it here.

Add align-items: flex-start; to .row and the short card shrinks back to fit its words.