FrontendIntermediateCSS
Flexbox
PronunciationFLEKS-boks
Definition
Flexbox is a CSS layout module designed to distribute space and align items within a container, even when their size is unknown or dynamic. It allows elements to easily align as a single row or column.
Where you hear it
During frontend development meetings, CSS styling discussions, or when building responsive layouts.
Examples
Use Flexbox to center a button inside a navigation bar.
We switched from floats to Flexbox to make the layout more responsive.
Flexbox keeps the logo and the menu on one row, even when the screen narrows.
Common mistake
Trying to use Flexbox for complex two-dimensional layouts, where CSS Grid would be a more appropriate and efficient tool.
Don't confuse with
Flexbox is designed for one-dimensional layouts in either a row or a column, while CSS Grid is built for two-dimensional layouts controlling both rows and columns simultaneously.
Say it at work
- In a meeting or chat
Can we use Flexbox here so these items wrap nicely on smaller screens?
- In an email or ticket
I updated the container style to use Flexbox for better alignment of the action buttons.