css · level 2 · unit 2 · lesson 1
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
justify-content has more values than center.
You know center and space-between. Unless told otherwise, children bunch at , the start of the main axis. bunches them at the far end instead: the right of a row.
makes every gap equal, including the gaps at both edges. space-around gives each child equal room on both sides, so the edge gaps come out half the size.
All of these share out free space without changing the children's size. If a child has flex-grow, there is no free space left to share.
<div class="actions">
<button>Cancel</button>
<button>Save</button>
</div> .actions {
display: flex;
justify-content: flex-end;
gap: 8px;
padding: 12px;
background-color: whitesmoke;
} Press show my page to see it here.
Try space-evenly, then space-around, and compare the gaps at the edges.
guess first
flex-end in a column. Where do the links go?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
<div class="side">
<a href="https://example.com/settings">Settings</a>
<a href="https://example.com/logout">Log out</a>
</div> .side {
display: flex;
flex-direction: column;
justify-content: flex-end;
height: 220px;
background-color: whitesmoke;
}
your turn
Your turn. Space out the dock.
Spread the four pictures so the gaps between them and at both edges are all the same size.
the page you’re styling
<div class="dock">
<img src="cat.svg" alt="Pets">
<img src="ball.svg" alt="Games">
<img src="cake.svg" alt="Recipes">
<img src="tree.svg" alt="Walks">
</div>your css
Press show my page to see it here.
- the gaps are equal everywherenot checked yet
fix it
The link should sit at the far right. Fix it!
the page you’re styling
<div class="pager">
<a href="https://example.com/page-2">Next page</a>
</div>your css
Press show my page to see it here.
- the link sits at the far endnot checked yet
text-alignmoves words inside a box. What moves flex children?- Flex children move along the main axis with
justify-content. - Replace
text-align: right;withjustify-content: flex-end;, then press run.
nailed it
you can send children to any spot. :D
flex-startis where children bunch;flex-endis the far end.space-evenlymakes every gap equal, edges included.text-alignmoves words, not flex children.
new words in your collection
- flex-start
- flex-end
- space-evenly
This lesson isn’t saved. A free account remembers every lesson you finish.