Categories
CSS Flexbox Generator
Generate CSS Flexbox styles for the container and each item while watching a live preview.
Click an item in the preview to configure it individually.
Overview
Generates CSS Flexbox styles just by specifying flex-direction, justify-content, align-items, flex-wrap, and gap.
You can add 1 to 12 items and set flex-grow, flex-shrink, flex-basis, order, and align-self for each item.
The preview and the generated CSS update as soon as you change a value, so you can adjust the layout while watching how the items are arranged.
Useful for building layouts commonly done with Flexbox, such as navigation bars or a row of cards.
Usage
- 1
In "Container (parent) settings", choose flex-direction, justify-content, align-items, and flex-wrap from the dropdowns, and enter the gap (px).
- 2
If needed, change the number of items with "Add item" and "Remove selected item".
- 3
Click an item in the preview to select it, then enter values such as flex-grow in its settings.
- 4
The preview and CSS update with every change. Copy the result to use it.
Example
Input
row / space-between / center / wrap / 16px, item 2 flex-grow: 1
Output
.container { display: flex; flex-direction: row; ... } .item-2 { flex-grow: 1; }Use Cases
Quickly generating CSS to arrange elements in a row, such as a navigation bar or toolbar
Building a layout that arranges cards or buttons with even spacing while watching the preview
Learning the difference in behavior between justify-content and align-items by checking an actual preview
Building a layout where only some items grow (flex-grow), such as a sidebar and a main area
FAQ
Can I also generate a vertical (column) layout?
Yes. Choose "column" or "column-reverse" for flex-direction.
Can I set different flex-grow / flex-shrink values per item?
Yes. Click an item in the preview to select it, and you can set its flex-grow, flex-shrink, flex-basis, order, and align-self. In the generated CSS, each item is output with a class name showing its position, such as .item-1 and .item-2.
Does this work in Internet Explorer?
The generated properties (including gap) work in major modern browsers (Chrome, Firefox, Safari, Edge). Internet Explorer is not supported.
Notes
The gap can be 0 to 500px, flex-grow and flex-shrink 0 to 99, flex-basis 0 to 2000px (leave empty for auto), and order -99 to 99.
For items, only properties changed from their initial values are output. Items left at their initial values are omitted.
Class names such as .container and .item-1 are examples. Rename them to match your actual HTML.
Related Tools
Generate CSS Grid styles from column count, row count, and gap.
Generate linear-gradient or radial-gradient CSS from colors and positions.
Generate multi-size favicon PNGs, a manifest, and HTML tags from an image.