Visually build and customize CSS Flexbox layouts. Configure container direction, wrapping, alignment, gaps, and individual item properties with real-time preview and exportable CSS.
flex-direction to column on smaller screens, a standard best practice for responsive web design.
Click any preset to instantly apply container direction, wrapping, alignment, and sample item styles:
/* Generating CSS Flexbox... */
The CSS Flexible Box Layout (Flexbox) module provides a 1-dimensional layout model designed to distribute space between items in an interface and improve their alignment capabilities across different screen sizes and display devices.
display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: 16px;
The main axis is defined by flex-direction (horizontal for row, vertical for column). The cross axis always runs perpendicular to the main axis.
Aligns items along the main axis. Controls distribution of extra space using keywords like flex-start, center, space-between, and space-evenly.
Aligns items along the cross axis on the current line. Common values include stretch (default), flex-start, center, and baseline.
Shorthand for three sub-properties: flex-grow (proportion of extra space to consume), flex-shrink (rate of shrinking when space is tight), and flex-basis (initial size).
| Property / Concept | CSS Flexbox | CSS Grid Layout |
|---|---|---|
| Dimensionality | 1-Dimensional (linear flow along a row OR column) | 2-Dimensional (controls columns AND rows simultaneously) |
| Approach | Content-First (items determine their own flow & wrapping) | Layout-First (rigid track matrix defined on container) |
| Item Spanning | Items cannot span across multiple rows without custom JS | Items easily span multiple columns & rows with grid-column & grid-row |
| Gap Support | Full standard support with gap, row-gap, column-gap |
Full standard support with gap, row-gap, column-gap |
| Ideal Use Cases | Navbars, pill button bars, header bars, form controls, linear card strips | Page layouts, dashboards, complex cards grids, image galleries |
display: flex; to the parent container, and add both justify-content: center; (centers along the main axis) and align-items: center; (centers along the cross axis). You can also apply margin: auto; to a flex child inside a flex container.
flex: 1; is shorthand for flex-grow: 1; flex-shrink: 1; flex-basis: 0%;. It instructs the browser to allow the item to grow and shrink proportionally to fill all leftover space in the container equally alongside other flex: 1 siblings.
flex-wrap: nowrap;, which forces all items onto a single line. To allow items to break into new rows or columns when container space runs out, set flex-wrap: wrap; on the parent container.
justify-content controls item alignment along the main axis (horizontal in row, vertical in column). align-items controls item alignment along the perpendicular cross axis (vertical in row, horizontal in column).
align-self, adjust their space consumption via flex-grow, flex-shrink, and flex-basis, or alter their visual display sequence using the order property.
pacestools-flexbox.css stylesheet containing all your container and item classes, ready for inclusion in your web projects.