The flex shorthand in CSS
Grow, shrink and basis, and the three values worth memorising.
.sidebar {
flex: 0 0 16rem;
}
.content {
flex: 1 1 0;
min-width: 0;
}
.icon {
flex: 0 0 1.5rem;
}
.spacer {
flex: 1 1 auto;
}
How it works
flex: 1means grow equally and ignore the content width.flex: 0 0 autorefuses to grow or shrink.flex-basisbeatswidthfor a flex item.
Keywords and builtins used here
contentflexiconremsidebarspacer
The run, in numbers
- Lines
- 16
- Characters to type
- 128
- Tokens
- 46
- Three-star pace
- 80 tpm
At the three-star pace of 80 tokens a minute, this run takes about 34 seconds.
Step 4 of 6 in Flexbox, step 4 of 24 in Flexbox & grid.