Flex alignment in CSS
Justify along the main axis, align along the cross axis.
.header {
display: flex;
justify-content: space-between;
align-items: center;
gap: 1rem;
}
.header .account {
margin-inline-start: auto;
}
.centered {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
How it works
justify-content: space-betweenpushes the ends apart.align-itemslines children up across the axis.margin-inline-start: autoshoves one child to the far end.
Keywords and builtins used here
accountcentereddisplaygapheaderremvh
The run, in numbers
- Lines
- 17
- Characters to type
- 234
- Tokens
- 52
- Three-star pace
- 80 tpm
At the three-star pace of 80 tokens a minute, this run takes about 39 seconds.
Step 2 of 6 in Flexbox, step 2 of 24 in Flexbox & grid.