CSS Flexbox Playground

Preview Flexbox settings and start from navigation, centered or card-layout examples.

On-device No sign-up Free to use

Generate Flexbox CSS controls

?

Affects the preview only. The copied CSS works for any number of items.

Processed in your browser. Your inputs stay on this device.

Showing an example. Change the fields, then use generate flexbox css to update it.

Result

Showing an example.

Lay out six preview items in wrapping rows with a 16-pixel gap.

Generated Flexbox CSS for 6 items: row, wrap, justify-content flex-start, align-items stretch, 16px gap. Copy the container and item rules below.

Loading the tool. Your result will appear here.

https://usefreetools.net/css-flexbox-playground · 20 November 2026

Was this helpful?

How to use CSS Flexbox Playground

  1. Choose a direction and wrapping behavior, or start with a Navigation, Centered or Cards example.
  2. Set main-axis and cross-axis alignment, gap, item basis, grow and shrink. Change the preview item count to see how a shared sizing rule responds.
  3. Select Generate Flexbox CSS and copy both rules. Replace .container and .item with your selectors, then test with real content at the intended widths.

Example: CSS Flexbox Playground

Lay out six preview items in wrapping rows with a 16-pixel gap.

You add
flex-direction: row; flex-wrap: wrap; justify-content: flex-start; align-items: stretch; Gap (px): 16; Item basis (px): 80; Item flex-grow: 0; Item flex-shrink: 1; Preview items: 6
You get
Generated Flexbox CSS for 6 items: row, wrap, justify-content flex-start, align-items stretch, 16px gap. Copy the container and item rules below.

Options

Direction and wrapping
Direction sets the main axis. row follows the inline axis and column follows the block axis; reverse variants change visual order. Wrap allows another line when items do not fit. Keep a logical source and keyboard order.
Gap and preview count
Gap accepts 0 to 96 pixels. The sample count ranges from 3 to 12 and affects only the preview; it is not included as a restriction in the CSS.
justify-content
Distributes available space along the main axis. For example, center groups items in the middle and space-between puts free space between them. Switching row to column changes which axis this controls.
align-items
Positions items on the cross axis. stretch can expand items across their line, while flex-start, flex-end, center and baseline use the selected alignment. This controls all items rather than an individual align-self override.
Item sizing
All sample items share one flex rule. Basis accepts 20 to 400 pixels and supplies the starting main-axis size. Grow and shrink accept 0 to 5 and determine how the items share extra space or shrink when space is short.

Supported inputs and limits

  • Three to twelve sample items with one shared sizing rule and bounded numeric settings.
  • It does not generate arbitrary per-item rules or your site’s breakpoints.
  • Intrinsic text sizes and the available container space affect wrapping.
  • Example buttons fill editable layout fields.
  • Per-item visual overrides and Tailwind output are not provided.

Where your input is processed

This tool does not upload your inputs. See the limits for anything saved on your device.

Choose alignment for the current axis

The main axis follows flex-direction. Justify-content works along it; align-items works across it. Switching from row to column changes which screen direction those properties control.

Questions about CSS Flexbox Playground

Why do items wrap earlier on my page?

Their content, padding, border and minimum sizes can differ from the sample. The container width also determines the room available.

What does flex-basis set?

It supplies an item’s starting main-axis size before free space is distributed or the items shrink.

Does reverse direction change reading order?

It changes visual order. Keep a logical source order for keyboard and assistive-technology users.

Page updated · Project managed by Tony Hines · Report a problem with CSS Flexbox Playground