Bootstrap exposes flex helpers that mirror CSS flexbox: d-flex, flex-column, justify-content-between, align-items-center, and gap-* (Bootstrap 5.1+).
Common patterns
- Toolbar:
d-flex justify-content-between align-items-center - Stacked mobile / row desktop: combine with responsive display (
d-md-flex) - Equal-height cards:
d-flex flex-column h-100on card innards
Tailwind names the same ideas without the d- prefix (flex justify-between). Bootstrap flex utilities complement the grid—use flex for one-dimensional toolbars, grid for page-level columns.
Important interview questions and answers
- Q: Flex utilities or grid for a page shell?
A: Grid (.row/.col) for main layout columns; flex for nav bars, media rows, and inline control groups. - Q: Why gap-* over margin on every child?
A: Gap spaces between items only—no first/last edge hacks, same rationale as Tailwind’sgap-4.
Self-check
- Which utilities center content on both axes inside a flex container?
- When would you use
flex-columnon a toolbar?