×

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

display: flex lines the children up in a row.

A is an element sitting directly inside another one, its parent. Give the parent display: flex and its children stop stacking up. They line up side by side in a row.

This way of laying things out is called . Most menus, toolbars and rows of cards on the web are built with it.

sets the space between the children, like gap: 12px. It only adds a gap between them, never round the outside edges.

<div class="row">
  <div class="tile">Red</div>
  <div class="tile">Amber</div>
  <div class="tile">Green</div>
</div>
.row {
  display: flex;
  gap: 12px;
}
.tile {
  background-color: lightgray;
  padding: 16px;
}

Press show my page to see it here.

Remove display: flex and the tiles stack up again, one under another.