Students put boxes in a row with display flex, and find out that it goes on the box that holds them, not on the items.
Load these into Waypoints Prepare: choose Load URL and paste the copied address, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.
Predict and Run 10 min · Investigate 12 min · Mix it up 4 min · Modify 10 min · Make 9 min
Read the unit primer "Layout and components in 5 minutes", then do the Make task yourself.
The one idea of the lesson: display: flex; goes on the parent (the box that holds the items), and its children line up in a row. Only the direct children line up. Spacing, centring and wrapping are the next lessons, so here the space between items is a margin on each item. list-style: none; is not Flexbox: it removes a list's bullets, which every real menu does.
ul to rearrange its items. It does, because the items are its children. Ask one pair from each answer to say why. Listen for who says bullets: list-style is not Flexbox.display: flex; to see the switch.display: flex on each li: each item lines up its own insides, so nothing visible changes and there is no error.nav a picks, and where padding goes.display: flex.On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.
Swap menus with a partner. Point at the box that holds the items and the boxes that line up, then say which rule has display flex.
Listen for students who point at the links. Ask what the links sit inside.
display: flex goes on the parent, not the items. When the row doesn't appear, ask which box holds the items before saying anything else.
| What you will see | A question to ask | The fix |
|---|---|---|
| The items still stack after adding display flex. | Which box did you put display flex on? Is it the box that holds the items? | Move display flex to the parent's rule (the ul, or the div that holds the cards). |
| The words in the row touch each other. | What puts space outside each item? | Add a margin to the li items, such as margin-right 24px. The next lesson has a better tool for the space between items. |
| Bullets sit oddly beside the menu items. | What removes a list's bullets? | Add list-style none; to the ul's rule. |
One possible solution for each task. Other correct programs are fine.
<style>
.menu {
display: flex;
list-style: none;
}
.menu li {
margin-right: 24px;
}
.card {
padding: 8px;
border: 2px solid teal;
margin: 6px;
}
</style>
<ul class="menu">
<li><a href="https://example.com/home">Home</a></li>
<li><a href="https://example.com/events">Events</a></li>
<li><a href="https://example.com/join">Join</a></li>
</ul>
<div class="cards">
<div class="card">
<img src="trophy.svg" alt="Trophy" width="50">
<p>Owls</p>
</div>
<div class="card">
<img src="medal.svg" alt="Medal" width="50">
<p>Hawks</p>
</div>
<div class="card">
<img src="star.svg" alt="Star" width="50">
<p>Kestrels</p>
</div>
</div>
<style>
.menu {
display: flex;
list-style: none;
}
.menu li {
margin-right: 24px;
}
.cards {
display: flex;
}
.card {
padding: 8px;
border: 2px solid teal;
margin: 6px;
}
</style>
<ul class="menu">
<li><a href="https://example.com/home">Home</a></li>
<li><a href="https://example.com/events">Events</a></li>
<li><a href="https://example.com/join">Join</a></li>
</ul>
<div class="cards">
<div class="card">
<img src="trophy.svg" alt="Trophy" width="50">
<p>Owls</p>
</div>
<div class="card">
<img src="medal.svg" alt="Medal" width="50">
<p>Hawks</p>
</div>
<div class="card">
<img src="star.svg" alt="Star" width="50">
<p>Kestrels</p>
</div>
</div>
<style>
.menu {
display: flex;
list-style: none;
margin: 0;
padding: 0;
}
.menu li {
margin-right: 24px;
}
.cards {
display: flex;
}
.card {
padding: 8px;
border: 2px solid teal;
margin: 6px;
}
</style>
<ul class="menu">
<li><a href="https://example.com/home">Home</a></li>
<li><a href="https://example.com/events">Events</a></li>
<li><a href="https://example.com/join">Join</a></li>
</ul>
<div class="cards">
<div class="card">
<img src="trophy.svg" alt="Trophy" width="50">
<p>Owls</p>
</div>
<div class="card">
<img src="medal.svg" alt="Medal" width="50">
<p>Hawks</p>
</div>
<div class="card">
<img src="star.svg" alt="Star" width="50">
<p>Kestrels</p>
</div>
</div>
<style>
header {
background-color: lightblue;
padding: 12px;
}
.menu {
display: flex;
list-style: none;
margin: 0;
padding: 0;
}
.menu li {
margin-right: 24px;
}
</style>
<header>
<h1>Robotics Club</h1>
<nav>
<ul class="menu">
<li><a href="https://example.com/home">Home</a></li>
<li><a href="https://example.com/events">Events</a></li>
<li><a href="https://example.com/join">Join</a></li>
</ul>
</nav>
</header>
<h2>We meet every Tuesday at lunch.</h2>
Stretch: Make the cards a row too, with a picture in each, and predict what happens if a card has display flex as well.
Support: Give students the Modify starter and do the first task together, saying out loud: the menu is the parent, so display flex goes in .menu.
A student wants three cards side by side. They write .card { display: flex; } but the cards still stack. What is wrong, and what should they write?
display flex is on the items. It goes on the box that holds the cards, for example .cards { display: flex; } with the cards inside a div with class cards.
Next lesson spaces the row out: gap, justify-content and align-items, so the club name sits left and the menu right. Class idea: find three websites and sketch which parts are Flexbox rows (menus, toolbars, rows of cards).