Home Tools Blog About

CSS Flexbox Generator

In short

A visual flexbox builder: set the container, click any item to change how it grows and shrinks, and copy the CSS, HTML or Tailwind classes. Presets cover common layouts.

  • Runs in your browser
  • Nothing uploaded
  • Free, no sign-up
Live preview click an item to edit it

Selected itemItem 1
The preview is plain CSS in your browser. Nothing is sent anywhere.
🛡
Private by designYour files and text stay in this tab
⚡
Runs in your browserNo waiting for a server
💧
No watermarksClean output you can use
🆓
FreeNo account needed

How to Use CSS Flexbox Generator

CSS Flexbox Generator · free online tool · All Tools Verse
The CSS Flexbox Generator tool, as it looks in your browser.
  1. Pick a preset such as "Sidebar left, main right", or start from the four default items.
  2. Change the container settings (direction, wrap, justify-content, align-items, gap) and watch the preview.
  3. Click an item in the preview to set its flex-grow, flex-shrink, flex-basis, order and align-self.
  4. Copy the CSS, the HTML or the Tailwind classes, or download a .css file.

Example: a fixed sidebar with a flexible main area

The “Sidebar left, main right” preset gives the sidebar a fixed 240px and lets the main column take the rest. The tool writes only the values that differ from the defaults:

.container {
  display: flex;
  gap: 16px;
  min-height: 220px;
}

.container > :nth-child(1) {
  flex: 0 0 240px;
}

.container > :nth-child(2) {
  flex: 1 1 0%;
}

The same layout as Tailwind classes:

Container: flex gap-4 min-h-[220px]
Item 1: shrink-0 basis-[240px]
Item 2: flex-1

flex: 0 0 240px means the sidebar neither grows nor shrinks. flex: 1 1 0% starts the main column at zero width and lets it take all remaining space, so long content inside it cannot push the sidebar narrower.

Flexbox properties at a glance

Property Set on Default What it does
flex-direction container row Sets the main axis: a row (left to right) or a column (top to bottom), optionally reversed.
flex-wrap container nowrap Lets items move to a new line when they run out of room.
justify-content container normal (acts as flex-start) Spreads free space along the main axis: start, end, center, between, around, evenly.
align-items container normal (acts as stretch) Lines items up across the main axis.
align-content container normal Spaces the lines of wrapped items. Does nothing with nowrap.
gap container 0 Space between items, without margins on the outer edges.
flex-grow item 0 Share of the free space the item takes.
flex-shrink item 1 How much the item gives up when space is short. 0 keeps its size.
flex-basis item auto Starting size before growing or shrinking.
order item 0 Visual order. Screen readers and Tab still follow the HTML order.
align-self item auto Overrides align-items for one item.

Layouts the presets build

  • Center one item: justify-content: center and align-items: center on the container.
  • Navbar: the second item gets margin-left: auto, which pushes it and everything after it to the right.
  • Wrapping card grid: flex-wrap: wrap with flex: 1 1 220px on each card, so cards are at least 220px wide and stretch to fill each row.
  • Sticky footer: a column where the middle item has flex-grow: 1, which pushes the footer to the bottom of the container.
  • Holy grail: two fixed side columns of 180px and a flexible main column between them.

How it works

The preview is a real flex container styled with the same values the tool writes, so what you see is what the CSS does. Item rules use :nth-child() selectors so you can paste them without adding classes. Under the preview, a sentence explains in plain words what the current justify-content and align-items do.

Limits

  • Flexbox lays things out in one direction. For a layout that needs rows and columns lined up at the same time, CSS Grid is the better tool.
  • Tailwind output uses arbitrary values such as basis-[240px] where no standard class exists, which needs Tailwind 3 or later.

Frequently asked questions

How do I center a div with flexbox?

Put display: flex, justify-content: center and align-items: center on the parent, and give the parent a height. The “Center one item” preset writes exactly this.

What is the difference between justify-content and align-items?

justify-content works along the main axis (horizontal in a row), align-items works across it (vertical in a row). With flex-direction: column the two swap directions.

Why does my flex item not shrink below its content?

Flex items have min-width: auto, so they will not shrink below their longest word or widest image. Add min-width: 0 to the item, or use flex-basis: 0 with flex-grow as the main column preset does.

What does flex: 1 mean?

It is shorthand for flex: 1 1 0%: grow with a share of 1, shrink if needed, and start from zero width. Several items with flex: 1 get equal widths.

Keep going

Related Tools

All Developer tools →

CSS Animation Generator →

Creates CSS animations from 20 presets or your own keyframes, with a live preview,…

CSS Aspect Ratio →

Generate CSS aspect-ratio with padding-top fallback, object-fit options, 16+ presets, decimal input. Live preview.…

CSS Beautifier →

Formats CSS with clean indentation or minifies it to the smallest safe size. Choose…

CSS Border Radius Generator →

Visual CSS border-radius with elliptical mode, 6 unit types (px/%/em/rem/vw/vh), 8 shape presets, live…

CSS Clip Path Generator →

Builds clip-path shapes visually: drag the points of a polygon, resize a circle or…

CSS Columns Generator →

Generate CSS multi-column layout with column-count or column-width, gap, rule, fill, span, break-inside. Live…

CSS Cursor Generator →

Browse 34 CSS cursors organized by category, with custom URL cursor builder. Live hover…

CSS Filter Generator →

Generate CSS filter with 10 functions including drop-shadow, backdrop-filter mode, 8 preset combinations. Live…

CSS Glassmorphism Generator →

Builds frosted glass CSS with backdrop-filter. Preview it on four test backgrounds, see an…

CSS Gradient Generator →

Design a linear, radial or conic CSS gradient by dragging color stops on a…

CSS Grid Generator →

Visual CSS Grid builder with grid-template-areas, auto-fit + minmax responsive tracks, per-item spans. 6…

CSS Media Query Generator →

Build @media queries: width, dark mode, reduced-motion, hover, pointer, orientation, print. Free, offline, client-side,…

Share

Embed this tool

Add this free tool to your website. Copy and paste the code: