CSS Flexbox Generator
Build a flexbox layout with a live preview: container and single items, ready layouts, and code as CSS, HTML or Tailwind.
Build a flexbox layout with a live preview: container and single items, ready layouts, and code as CSS, HTML or Tailwind.
About this tool
CSS Flexbox Generator lets you build a flexbox layout by looking at it. Change a setting and the preview follows; the code below is ready to copy as CSS, as HTML or with Tailwind classes. For the container you set the direction, how items are placed along it (justify-content), across it (align-items), whether they wrap into several lines, the space between those lines (align-content) and separate gaps for rows and columns. A short note tells you which way justify-content and align-items move things, because they swap when the direction is a column, which confuses almost everybody at first. Tap an item in the preview to change only that one: how much free space it takes (flex-grow), whether it may get smaller (flex-shrink), its starting size (flex-basis), its own alignment (align-self) and its order. Add or remove items, up to twelve. Make the preview narrower to see how the layout behaves on a phone, and switch to right to left to check it for Arabic or Hebrew. Ready layouts give you a start: centered content, a navigation bar, cards that wrap, a sidebar next to the content, and a footer that stays at the bottom. The cards layout, for example, uses flex: 1 1 180px on each item, so cards share the row and move to a new line when there is less than 180 pixels for each. The code contains only what differs from the defaults, which keeps it short and shows what really matters. One warning about order: it changes only how items look, while keyboards and screen readers still follow the HTML, so do not use it to rearrange content that has a reading order. Flexbox lays out in one direction at a time; for rows and columns together, CSS grid is the better tool.

Or from three plain items.
Direction, alignment, wrapping and gaps.
Change its size, alignment or order.
CSS, HTML or Tailwind.
With a width slider.
Grow, shrink, basis, alignment and order.
Five common ones.
Defaults are left out.
Common layouts
Logo on the left, links on the right.
Examplejustify-content: space-between
Put something in the exact middle.
ExampleCenter both directions.
Cards that wrap on small screens.
Exampleflex: 1 1 180px
A fixed sidebar and flexible content.
Exampleflex: 0 0 160px and flex: 1 1 auto
Keep the footer at the bottom.
ExampleA column with a growing middle.
Change one value and watch.
ExampleCompare grow 1 with grow 2.
Layouts that hold
justify-content follows the direction; align-items goes across.
It is simpler than margins and leaves no space at the edges.
Set min-width: 0 on an item so long text can shrink.
order does not change the reading order.
Senior Software Engineer · Developer of Toolyconvert
Hemant developed CSS Flexbox Generator and tests it on desktop and mobile with real files. He is a senior software engineer from Dehradun, India, building websites since 2014, and designed and developed Toolyconvert end to end.
Last updated 25 November 2026
Featured on
Toolyconvert is listed on these product directories and launch platforms.