×

css · level 2 · unit 2 · lesson 3

  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

and auto margins move one child on its own.

align-items sets the cross-axis spot for every child. align-self goes on one child and overrides it, for that child only. align-self: flex-end sends one card to the bottom of the row.

On the main axis, flexbox has no justify-self. Instead, margin-left: auto on a child soaks up all the free space to its left. It pushes that child, and everything after it, to the far end.

That is the classic menu bar: a logo on the left, and margin-left: auto on the first link to slide the links over to the right.

<nav class="menu">
  <a href="https://example.com/">Fresh Bakes</a>
  <a class="push" href="https://example.com/shop">Shop</a>
  <a href="https://example.com/help">Help</a>
</nav>
.menu {
  display: flex;
  gap: 16px;
  padding: 12px;
  background-color: bisque;
}
.push {
  margin-left: auto;
}

Press show my page to see it here.

<nav> is a box for a page's main links. It behaves like a <div>.