Flexbox
Laying things out side by side used to be hard. Flexbox makes it easy. Set display: flex on a container, and its direct children line up in a row:
.toolbar {
display: flex;
}
Then control how the children are arranged:
| Property | What it does | Common values |
|---|---|---|
flex-direction |
row or column | row (default), column |
justify-content |
spacing along the row | flex-start, center, space-between, space-around |
align-items |
alignment across the row | stretch (default), center, flex-start |
gap |
space between items | 8px, 1rem |
flex-wrap |
wrap onto new lines | nowrap, wrap |
These go on the container. On a child, flex: 1 makes it grow to fill spare space.
Centring anything
The classic "how do I centre this?" problem, solved:
.screen {
display: flex;
justify-content: center;
align-items: center;
height: 300px;
}
Your task
Make the .menu a flex container where:
- the items are spread across the width with
space-between, - they are vertically centred,
- there is a
12pxgap between them.