Change the container and item settings, see the result in a live preview straight away and copy ready-made CSS and HTML. The tool writes only the lines that differ from the defaults, so the output stays clean. Everything runs in your browser and no value is ever sent to a server.
align-content only does anything once there is more than one line. To activate it, set flex-wrap to wrap or wrap-reverse.
|
justify-content aligns along the main axis, align-items along the cross axis. Changing flex-direction swaps those two axes, which is why the same setting can produce a completely different result.
Click a box to select it and change its settings. Width and height are for the preview only and never reach the output.
The moment you give an element display: flex, that element becomes a flex container and its direct children become flex items. From there, two axes govern the layout: the main axis and the cross axis. flex-direction decides which is which. With row the main axis runs horizontally and the cross axis runs vertically; switch to column and the two swap places.
That sounds like a footnote, but it changes everything. justify-content always works on the main axis and align-items always works on the cross axis. In a row, justify-content: center centers things horizontally; flip flex-direction to column and the same line starts centering them vertically. This is where most Flexbox confusion comes from, which is why the axis hint in the tool stays on screen at all times.
flex is shorthand for three properties: flex-grow, flex-shrink and flex-basis. When you write flex: 1, the browser expands it to flex: 1 1 0%. So you are not only setting a growth factor, you are also resetting the item's base size.
That is the whole difference. flex-grow: 1 on its own leaves flex-basis at auto, so every item starts at the width of its own content and only the leftover space gets shared out. Items with more text end up wider. flex: 1 zeroes the base size instead, so every item gets the same width no matter what is inside it. Reach for flex: 1 when you want equal columns, and flex-grow: 1 when you want columns that stay proportional to their content.
Flex items default to flex-shrink: 1, so they shrink when space runs out. But there is a floor: an item will not go below its own min-content size. A long unbroken word, a table that will not reflow, or a string with nowhere to wrap will hold the item at its width and push it out of the container.
The fix is min-width: 0 on that item, or min-height: 0 in a column layout. It removes the implicit min-content floor and lets the item actually shrink. Nearly every case of text-overflow: ellipsis or overflow: hidden mysteriously doing nothing inside a flex item is solved by that one line.
Both align on the cross axis, but they align different things. align-items positions items within their own line. align-content positions the whole set of lines within the container.
With a single line, align-content does nothing at all, because there is no second line to push around. That is why the align-content buttons in the tool look inert while flex-wrap is nowrap. Turn wrapping on first, and the control starts to matter.
Spacing items used to mean adding margin-right to every child except the last one. gap removes the trick entirely: it only puts space between items, never at the outer edges, and it handles the vertical spacing once lines start wrapping. Flexbox gap has shipped in every current browser since 2021, so there is no reason to avoid it today.
order moves items around on screen but leaves the HTML order untouched. Anyone tabbing through the page, and every screen reader, follows the source order instead. When the visual order and the reading order disagree, the page becomes hard to navigate.
Use order for small corrections and write the real structure in the correct order in your HTML. The same warning applies to row-reverse and wrap-reverse.
| Aspect | Flexbox | Grid |
|---|---|---|
| Axes | One axis | Two axes |
| Starting point | The content | The layout plan |
| Alignment behaviour | Each line is independent | Columns stay aligned across every row |
| Best suited to | Navigation bars, button groups, tag lists, the inside of a card | Page skeletons, galleries, dashboard layouts |
| Spacing | gap is supported | gap is supported |
In practice they are not rivals. The common approach is to build the page skeleton with Grid and then use Flexbox inside it for the card header, the button group or the navigation bar. If rows and columns have to stay aligned with each other, use Grid. If you need one direction of flow that stretches around its content, use Flexbox.
The tool only writes the lines that differ from the CSS initial value. flex-direction: row, flex-wrap: nowrap and align-items: stretch are already the browser default, so they never reach the output. An item you never customised gets no rule of its own either. The block you copy therefore adds nothing your stylesheet does not need.
If you need a quick result on the background and color side as well, the CSS gradient generator works the same way: change the settings, watch the preview, copy the code.
flex-direction sets the main axis: row lays items out horizontally, column vertically. If you want items to move to the next line when they no longer fit, set flex-wrap to wrap; align-content only starts working after that.
justify-content aligns along the main axis, align-items along the cross one, and the axis note on screen tells you which is which at any moment. Leave row-gap and column-gap linked and the output uses the single line gap shorthand.
Click a box in the preview to select it, then change its flex-grow, flex-shrink, flex-basis, align-self and order. Each box shows its current flex shorthand above it, so you can see what every setting does as you change it.
The tool writes only the lines that differ from the defaults, which keeps the output short. Copy the CSS and the HTML panels separately; the class names match exactly across the two.
Flexbox is one dimensional and content driven: items flow in a single direction and their size largely follows their content. Grid is two dimensional and layout driven: you define the rows and columns up front. Flexbox fits navigation bars, button groups and the inside of a card, while Grid fits the overall page skeleton. Using both on the same page is normal and usually the right call.
No. The flex: 1 shorthand expands to flex: 1 1 0%, so it also zeroes flex-basis and every item ends up the same width regardless of its content. flex-grow: 1 on its own leaves flex-basis at auto, so items start at their content width and only the leftover space is shared. Use flex: 1 for equal columns and flex-grow: 1 for columns that stay proportional to their content.
Flex items do shrink by default, but never below their own min-content size. A long URL, an unbreakable word or a table will hold the item at its width. Adding min-width: 0 to the item, or min-height: 0 in a column layout, removes that implicit floor. Most cases where text truncation or overflow hiding seems broken inside a flex item are fixed by that single line.
align-items aligns items inside their own line, while align-content aligns the whole set of lines inside the container. With a single line align-content does nothing, because there is no second line to position. To see the difference, turn flex-wrap on and give the container more height than the lines need.
Yes. Flexbox gap has shipped in every current desktop and mobile browser since 2021. gap only adds space between items, never at the outer edges, and it handles vertical spacing once lines wrap. The old pattern of adding a margin to every child except the last one is no longer necessary.
Give the container display: flex, justify-content: center and align-items: center. The only requirement is that the container has free space on the cross axis, which usually means it needs a height; without one, vertical centering has nothing to show. The centering preset in the tool sets this up in one click.
Yes, and it deserves care. order changes only the visual order; keyboard navigation and screen readers still follow the source order in the HTML. When the two disagree, the page becomes confusing for keyboard users. The safest approach is to get the real order right in the markup and keep order for small visual corrections.