StreetDocsPlayground
css
14 minLearning in Pidgin

Layout with Flexbox

Arrange items one line — di way Ada arrange her menu cards.

What you'll learn

  • Use display: flex
  • Center items with justify-content and align-items
  • Use gap for spacing

Before you start

  • boxes-and-spacing

Ada don get three menu cards, but dem dey stand for top-top each other. She wan arrange dem for one line side by side. Flexbox go do am.

display: flex

When you add display: flex to a container, e children go arrange themselves for one line (by default). Dis one na di easiest way to make a row of items.

.menu-list {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
}
  • justify-content — how di items dey sit along di main line (center, space-between...)
  • align-items — how dem dey line up across di line
  • gap — di space between each item

Now Ada's three cards go stand for one line, centered and evenly spaced. Her menu don look professional!

Try it yourself

Flexbox menu list

Open in playground →
css
.menu-list {
  display: flex;
  justify-content: center;
  gap: 16px;
}

Quiz

Small check

Answer di questions below.

1. Which property dey arrange children for one line?

2. Which property dey set di space between flex items?