CSS Flexbox Playground
Experiment with CSS Flexbox properties visually. Adjust container and item properties, see results in real time, and copy the generated CSS. 100% client-side.
Layout Presets
Understanding CSS Flexbox
CSS Flexbox (Flexible Box Layout) is a one-dimensional layout model that makes it straightforward to distribute space and align content within a container. Unlike traditional layouts using floats or positioning, flexbox handles layout in a single direction (row or column) with powerful alignment and space distribution controls.
Container vs. Item Properties
Flexbox properties are split into two categories: container properties that go on the parent element (display: flex), and item properties that go on the children. Container properties like justify-content and align-items control the overall layout, while item properties like flex-grow and order control individual item behavior.
Main Axis and Cross Axis
Flexbox operates along two axes. The main axis is defined by flex-direction (horizontal for row, vertical for column). The cross axis runs perpendicular to it. justify-content aligns items along the main axis, while align-items aligns them along the cross axis.
The flex Shorthand
The flex property is shorthand for flex-grow, flex-shrink, and flex-basis. For example, flex: 1 0 auto means grow equally, don't shrink, and use auto for the base size. The common flex: 1 is shorthand for flex: 1 1 0%, which makes items share space equally.
Features
- Live visual preview with draggable item selection
- All 6 container properties: flex-direction, flex-wrap, justify-content, align-items, align-content, gap
- Per-item controls: flex-grow, flex-shrink, flex-basis, align-self, order
- Add or remove up to 12 flex items
- 6 common layout presets (navigation bar, card grid, holy grail, sidebar, centered, footer)
- Axis indicators showing main and cross axis directions
- Copy generated CSS code with one click
- 100% client-side — nothing is sent to any server
Browser Support
CSS Flexbox is supported in all modern browsers. The properties used in this playground work in Chrome, Firefox, Safari, Edge, and Opera without vendor prefixes. Flexbox has had excellent browser support since around 2015 and is safe to use in production.