Skip to content
gohacks.dev
Web

Flexbox Generator

Experiment with flex-direction, flex-wrap, justify-content, align-items and gap on a live preview, and copy the container CSS.

Free · No sign-up · Your inputs stay in your browser

Input

Build a flexbox layout

Output

CSS

143 characters

1
2
3
4
5

justify-content works along the main axis, which flex-direction sets, and align-items across it; switching to column swaps what the two do, which is the usual source of confusion. gap replaced the old margin tricks and is supported in flex layouts by every current browser.

Runs in this browser. Nothing you paste is sent to a server.

Main axis and cross axis

justify-content distributes items along the main axis, which flex-direction sets, and align-items aligns them across it. Switch to column and the two swap roles, which is the usual source of "centering does not work". MDN's flexbox basics walks through both axes.

gap replaced margins

The gap property sets space between flex items without margin hacks on first or last children, and is supported in flex layouts by every current browser. For two-dimensional layouts, rows and columns at once, grid is usually simpler.

Share

Frequently asked questions

How do I center something with flexbox?
On the container: display: flex; justify-content: center; align-items: center. Give it a height for vertical centring to be visible.
When should I use grid instead of flexbox?
Flexbox lays out along one direction and lets content decide sizes; grid lays out rows and columns together. Navigation bars suit flexbox, page layouts and card grids suit grid.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools