Lesson 4 of 8

Layout with Flexbox

Goal

Arranging and spacing out elements

01

Explanation

Flexbox lines elements up in a row or a column. Just write display: flex on the container, the element that holds them, and they fall into line on their own.

Then you control how they're spread out with three properties: gap for the space between the elements, justify-content for distributing them along the row, and flex-wrap: wrap so they move onto a new line instead of getting squeezed on narrow screens.

The row follows the page's text direction: it starts from the left on a left-to-right page and from the right on a right-to-left page, so you never have to reverse anything yourself.

02

Your task

Put the three items in a single row with space between them, spread them out evenly, and make them wrap onto a new line when the screen gets narrow.

Checks

4 checks
  1. The .row container is a flex container
  2. There is a gap of 12px or more between the items
  3. The items are spread out with space-between
  4. The items wrap onto a new line on narrow screens
03

Hints

0/3
index.html
Preview
index.html100%
–/4

Press “Run and check” to grade your code.

4 checks listed under “Your task”.