KickSolve • Free • Private

CSS Flexbox Generator

Build flexbox layouts visually. Change direction, alignment, wrapping and gap, tweak each item's grow, shrink, basis and order, and copy clean CSS and HTML.

Live flexbox previewPer-item controlsCopy CSS and HTML
Click an item in the preview to edit its own flex properties.

Selected item

CSS

HTML

How to use CSS Flexbox Generator on KickSolve

Three quick steps, no account needed.

Set the containerChoose flex-direction, justify-content, align-items, wrap, align-content and gap.
Edit the itemsClick an item and set its flex-grow, flex-shrink, flex-basis, align-self and order.
Copy the codeCopy the CSS and the matching HTML for your project.

Why choose KickSolve

Built for speed, privacy and clean results.

Private by designEverything runs in your browser and nothing is uploaded.
Learn while you buildSee immediately how each property changes the layout.
Clean, minimal codeOnly the item rules you changed are included in the CSS.
Fast and freeNo sign up and no limits.

What you can do with CSS Flexbox Generator

Everything this tool offers.

All container propertiesDirection, justify-content, align-items, wrap, align-content and gap.
Per-item controlsSet grow, shrink, basis, align-self and order for any item.
1 to 12 itemsTest layouts with the number of items you need.
Live previewSee every change instantly in a resizable-height preview.
CSS outputCopy a ready .container rule and item rules.
HTML outputCopy matching markup with numbered items.
Click to selectClick any item to edit it.
One-click resetReturn to the default layout at any time.

About CSS Flexbox Generator on KickSolve

What it does and how to get the best results.

How the flexbox generator works

The container settings on the right are applied to a live preview as inline styles, and the same values are written into the CSS you copy. Clicking an item lets you edit its own properties. Only item properties that differ from the defaults are included in the generated CSS, using nth-child selectors, so the code stays short.

Main axis and cross axis

Flexbox always works on two axes. The main axis follows flex-direction and is controlled by justify-content. The cross axis runs the other way and is controlled by align-items, align-self and, for wrapped lines, align-content. Most flexbox confusion comes from forgetting that column direction swaps the two.

Flex item properties

Flex-grow shares leftover space between items. Flex-shrink decides which items give up space first when the container is too small. Flex-basis sets the starting size. Align-self overrides align-items for one item, and order changes the visual position of an item.

Common flexbox layouts

  • Center anything: justify-content center and align-items center.
  • Navigation bar: justify-content space-between with a gap.
  • Responsive card row: flex-wrap wrap with a flex-basis on each card.
  • Sticky footer: flex-direction column with flex-grow 1 on the main content.
  • Equal height columns: leave align-items on stretch.

Flexbox vs CSS grid

Flexbox lays out items in one direction at a time and is ideal for components. CSS grid lays out rows and columns together and is better for whole page layouts. They work well together, and a grid cell can contain a flex container.

Good to know

  • The preview container has a fixed height of 320 pixels so vertical alignment is visible.
  • Align-content only affects layouts where items wrap onto more than one line.
  • The order property does not change keyboard or screen reader order.

Flexbox properties at a glance

Where each property is used and what it does.

PropertyApplies toWhat it does
flex-directionContainerSets the main axis: row or column, normal or reversed
justify-contentContainerAligns and distributes items along the main axis
align-itemsContainerAligns items along the cross axis
flex-wrapContainerAllows items to wrap onto new lines
align-contentContainerDistributes wrapped lines along the cross axis
gapContainerSets the space between items
flex-growItemHow much extra space the item takes
flex-shrinkItemHow much the item shrinks when space is short
flex-basisItemThe item's starting size
align-selfItemOverrides align-items for one item
orderItemChanges the visual order of the item

Frequently asked questions

Quick answers.

What is CSS flexbox?

Flexbox is a CSS layout model that arranges items in a row or a column and controls how they share space, align and wrap. You turn it on with display: flex on a container.

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

Justify-content aligns items along the main axis, which is horizontal for a row and vertical for a column. Align-items aligns them along the cross axis, which is the other direction.

How does flex-direction change the layout?

Flex-direction sets the main axis. Row places items left to right, column places them top to bottom, and the reverse values flip the order. It also swaps what justify-content and align-items do visually.

What do flex-grow, flex-shrink and flex-basis do?

Flex-grow decides how much extra space an item takes, flex-shrink decides how much it gives up when space is short, and flex-basis sets its starting size before growing or shrinking.

When does flex-wrap matter?

By default all items stay on one line and shrink to fit. Set flex-wrap to wrap to let items move to a new line, which is how responsive card rows work. Align-content then controls the space between the lines.

How do I center a div with flexbox?

Set display: flex, justify-content: center and align-items: center on the parent. Give the parent a height, and the child will be centered both ways.

Does the gap property work with flexbox?

Yes. Gap works with flexbox in all current browsers and is simpler than adding margins to each item.

What does the order property do?

Order changes the visual order of items without changing the HTML. Screen readers and keyboard focus still follow the HTML order, so use it carefully.

Should I use flexbox or grid?

Use flexbox for one-dimensional layouts such as navigation bars, toolbars and card rows. Use CSS grid when you need to control rows and columns together.

Is anything uploaded or stored?

No. The generator runs in your browser and nothing is sent to a server.

More free tools from KickSolve

Related everyday tools.