PureDevTools

CSS Flexbox Generator

Visually build Flexbox layouts — direction, alignment, wrapping, gap, per-item controls — real-time preview

All processing happens in your browser. No data is sent to any server.

Presets

Container Properties

8px

Live Preview

Click an item in the preview to select it for editing.

Flex Items (3/12)

Item 1
grow:0 shrink:1 basis:auto
Item 2
grow:0 shrink:1 basis:auto
Item 3
grow:0 shrink:1 basis:auto

Item 1 Properties

0
1
0
.flex-container { display: flex; flex-direction: row; flex-wrap: nowrap; justify-content: flex-start; align-items: stretch; gap: 8px; }

You need to center a login form both horizontally and vertically, but you can never remember whether it’s justify-content: center or align-items: center that handles the vertical axis — and it depends on flex-direction. Instead of trial-and-error in DevTools, this generator lets you toggle every flexbox property visually and see the result instantly.

Why This Tool

CSS Flexbox has 13 container and item properties. The axis behavior flips when you switch between row and column direction, which makes the mental model tricky. This tool gives you a live visual canvas: change any property and immediately see how items reflow. The generated CSS updates in real time. Everything runs locally in your browser.

What Is CSS Flexbox?

CSS Flexible Box Layout (Flexbox) is a one-dimensional layout model that distributes space among items in a container along a single axis — either horizontally (row) or vertically (column). Unlike Grid (which is two-dimensional), Flexbox excels at distributing items along one direction.

.container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

Container Properties

flex-direction

Sets the main axis: row (left to right), row-reverse, column (top to bottom), column-reverse. This determines which direction justify-content distributes items.

justify-content

Distributes items along the main axis:

ValueEffect
flex-startItems packed to the start
flex-endItems packed to the end
centerItems centered
space-betweenEqual space between items, none at edges
space-aroundEqual space around each item
space-evenlyEqual space between and at edges

align-items

Aligns items along the cross axis:

ValueEffect
stretch (default)Items fill the cross axis
flex-startItems align to cross-start
flex-endItems align to cross-end
centerItems centered on cross axis
baselineItems align by text baseline

flex-wrap

Controls whether items wrap to new lines: nowrap (default — items shrink to fit), wrap (items flow to next line), wrap-reverse.

gap

Sets spacing between items without margins. Works in both directions.

Item Properties

Common Flexbox Patterns

Center anything:

.center { display: flex; justify-content: center; align-items: center; }

Navigation bar:

.nav { display: flex; justify-content: space-between; align-items: center; }

Equal-width columns:

.cols { display: flex; gap: 16px; }
.cols > * { flex: 1; }

Frequently Asked Questions

What is the difference between Flexbox and CSS Grid? Flexbox is one-dimensional — it handles layout in a row OR a column. CSS Grid is two-dimensional — it handles rows AND columns simultaneously. Use Flexbox for navbars, button groups, and centering. Use Grid for page layouts and card grids.

Why do my flex items shrink instead of wrapping? The default flex-wrap value is nowrap, so items shrink to fit the container. Add flex-wrap: wrap to allow items to flow to the next line when they run out of space.

What does flex: 1 mean? flex: 1 is shorthand for flex-grow: 1; flex-shrink: 1; flex-basis: 0%. It makes the item grow to fill available space equally with other flex: 1 siblings.

How do I push one item to the right in a flex row? Use margin-left: auto on the item you want pushed right. Auto margins in flexbox absorb all available space in that direction.

Does this tool send my data anywhere? No. All layout computation and CSS generation happens entirely in your browser. Nothing is transmitted to any server.

Related Tools

More CSS Tools