CSS Flexbox Layout
Complete guide to CSS Flexbox — container properties, item properties, alignment, wrapping, and common layout patterns.
Overview
Flexbox (Flexible Box Layout Module) is a CSS layout model designed for distributing space and aligning items in a container. Set `display: flex` on a container to create a flex formatting context. Children become flex items that can grow, shrink, and be aligned along the main and cross axes. Flexbox replaces many float and positioning hacks with a clean, predictable API.
Syntax
display: flex | inline-flexValues
Browser Support
Supported in all modern browsers. No vendor prefix needed. gap in flexbox: Chrome 84+, Firefox 63+, Safari 14.1+.
Try it visually
Use our visual display: flex generator to create and preview CSS code in real-time.
Open CSS Flexbox Layout ToolFrequently Asked Questions
Flexbox: one-dimensional layout (row OR column). Grid: two-dimensional layout (rows AND columns). Use flexbox for component-level layout (navbars, cards), grid for page-level structure.
On the container: `display: flex; justify-content: center; align-items: center`. This centers children both horizontally and vertically.
It is shorthand for `flex-grow: 1; flex-shrink: 1; flex-basis: 0%`. The item will grow to fill available space, sharing equally with other flex: 1 siblings.