×

css · level 1 · unit 7 · 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

Move flex children along the row, and up and down.

Once a parent has display: flex, two more properties arrange its children. moves them along the row, from left to right.

justify-content: center bunches them in the middle. space-between pushes the first child to the left edge and the last to the right, with the others spread between. It is a favourite for menus.

works the other way, up and down. When the parent is taller than its children, align-items: center puts them halfway down.

<div class="bar">
  <h1>Bakery</h1>
  <a href="https://example.com/order">Order now</a>
</div>
.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background-color: wheat;
}

Press show my page to see it here.

Try center in place of space-between to see the difference.