Flexbox Axes & Sizing
Flexbox distributes space along a single primary axis while aligning items across the perpendicular cross axis.
Toolbar With Trailing Action
.toolbar {
display: flex;
align-items: center;
gap: 0.75rem;
}
.toolbar-spacer {
margin-inline-start: auto;
}
Preventing Flex Child Overflow
Flex items default to min-width: auto, which can force a row wider than its container when children hold long unbroken strings. Reset min-width: 0 on the shrinking pane.
.media-body {
flex: 1 1 0%;
min-width: 0;
}
Common Flex Shorthands
| Shorthand | Expanded | Effect |
|---|---|---|
flex: 1 | 1 1 0% | Equal shares regardless of intrinsic content width |
flex: auto | 1 1 auto | Grows and shrinks proportional to content size |
flex: none | 0 0 auto | Locks width for icons, badges, and buttons |