CSS Flexbox Visualizer

Interactive CSS Flexbox layout builder with live preview. Set container and item properties, see results instantly, and copy production-ready CSS. Everything runs in your browser.

Preview width:
Live Preview
flex-direction
flex-wrap
justify-content
align-items
align-content
gap
px
3 Items

How to Use CSS Flexbox

CSS Flexbox (Flexible Box Layout) is a one-dimensional layout model designed for distributing space among items in a container. Enable it with display: flex on any element, and its direct children become flex items that you can align, order, and size with powerful properties.

Container Properties

flex-direction sets the main axis: row (left to right), row-reverse, column (top to bottom), or column-reverse. flex-wrap controls whether items wrap to new lines. justify-content distributes items along the main axis, and align-items aligns them on the cross axis. align-content controls spacing between wrapped lines. gap adds consistent spacing between items.

Item Properties

flex-grow controls how much an item grows to fill available space. flex-shrink controls how it shrinks when space is tight. flex-basis sets the initial size before growing or shrinking. order changes the visual order without altering the HTML. align-self overrides the container's align-items for a single item.

Features

Flexbox vs CSS Grid

Flexbox handles one-dimensional layouts (a row or a column) while CSS Grid handles two-dimensional layouts (rows and columns together). Use Flexbox for component-level layouts like navbars, card contents, and form groups. Use Grid for page-level layouts like headers, sidebars, and content regions. They work best when combined.

Browser Support

CSS Flexbox is supported in all modern browsers: Chrome 29+, Firefox 28+, Safari 9+, and Edge 12+. The gap property for Flexbox is supported in Chrome 84+, Firefox 63+, Safari 14.1+, and Edge 84+. No vendor prefixes are needed for any current browser.

Embed this tool on your site
<iframe src="https://devtoolbox.dedyn.io/tools/css-flexbox-visualizer" width="100%" height="900" frameborder="0"></iframe>

Frequently Asked Questions

What is CSS Flexbox?
CSS Flexbox (Flexible Box Layout) is a one-dimensional layout model that distributes space among items in a container. You enable it with display: flex on a container element. It excels at aligning items along a single axis (row or column), distributing space, and handling dynamic or unknown sizes. Flexbox is supported in all modern browsers and is the go-to choice for component-level layouts like navigation bars, card layouts, and form controls.
What is the difference between justify-content and align-items?
justify-content controls how flex items are distributed along the main axis (horizontal by default), while align-items controls alignment along the cross axis (vertical by default). For example, justify-content: center centers items horizontally, and align-items: center centers them vertically. When flex-direction is set to column, the axes swap.
What does flex-wrap do?
By default, flex items try to fit on one line (flex-wrap: nowrap). Setting flex-wrap: wrap allows items to flow onto multiple lines when they exceed the container width. flex-wrap: wrap-reverse wraps items in reverse order. When wrapping is enabled, align-content controls the spacing between wrapped lines.
What do flex-grow, flex-shrink, and flex-basis mean?
flex-grow determines how much an item grows relative to other items when extra space is available (default 0). flex-shrink determines how much it shrinks when space is insufficient (default 1). flex-basis sets the initial size before growing or shrinking (default auto). Together they form the flex shorthand: flex: grow shrink basis.
When should I use Flexbox vs CSS Grid?
Use Flexbox for one-dimensional layouts where items flow in a single row or column, such as navigation bars, button groups, or card content. Use CSS Grid for two-dimensional layouts that need control over both rows and columns simultaneously, such as page layouts, dashboards, or image galleries. They complement each other and are often used together.
Keyboard Shortcuts
Ctrl+Enter Generate CSS
Ctrl+Shift+C Copy CSS
Ctrl+L Reset all