Flexbox is a modern layout model in CSS that allows flexible alignment of elements in a row or column. It makes alignment, sizing, and ordering easier to handle.
Flexbox is activated with display: flex. Inside a flex container, elements are automatically arranged flexibly, with many settings available for alignment and distribution.
| Property | Description |
|---|---|
| display: flex | Creates a flex container in which child elements are arranged flexibly. |
| justify-content | Horizontal alignment, such as left, right, center, or evenly distributed. |
| align-items | Vertical alignment inside the flex container. |
| flex-direction | Defines the direction: row or column. |
In the following example, three elements are inside a flex container, displayed evenly distributed and centered.
With the combination of justify-content: space-around and align-items: center, the elements are evenly spaced and vertically centered.
Flexbox makes layout handling easier, especially in dynamic or responsive design.
✨ Ask Lara — your AI study partner
Unlock personalized learning support. Lara can explain lessons, summarize topics, and answer your study questions — available from the Go plan and above.
Lara helps you learn faster — exclusive to ReadyTools Go, Plus, and Max members.