About CSS Flexbox
CSS Flexbox (Flexible Box Layout) is a one-dimensional layout model that makes it easy to align and distribute space among items in a container, even when their size is unknown or dynamic.
Key Concepts
- flex-direction: Defines the main axis (row or column)
- justify-content: Aligns items along the main axis
- align-items: Aligns items along the cross axis
- flex-grow: How much an item grows relative to others
Frequently Asked Questions
What is the difference between justify-content and align-items?
justify-content aligns items along the main axis (horizontal in row direction), while align-items aligns them along the cross axis (vertical in row direction).
When should I use flexbox vs grid?
Use flexbox for one-dimensional layouts (a row or column). Use CSS Grid for two-dimensional layouts (rows and columns simultaneously).
What does flex-grow: 1 do?
It makes the item grow to fill available space. If multiple items have flex-grow: 1, they share the space equally.
Is flexbox supported in all browsers?
Yes, flexbox is supported in all modern browsers including Chrome, Firefox, Safari, and Edge.
