📦

Flexbox Generator

Design CSS flexbox layouts visually. Adjust all flex container and item properties with live preview and copy the ready-to-use CSS code. Free, browser-based.

💻 Developer Tools Free Browser-based
Tool
Container
flex-direction
flex-wrap
justify-content
align-items
align-content
Items
Number of items
4
flex-grow
flex-shrink
flex-basis
gap

What Is CSS Flexbox?

Flexbox (Flexible Box Layout) is a CSS layout model that makes it easy to align and distribute space among items in a container — even when their sizes are unknown or dynamic. Before Flexbox, centering elements and building responsive rows required fragile float hacks or table tricks. Flexbox solves alignment in one or two lines of CSS. It is a one-dimensional layout model — it handles either a row or a column at a time — which makes it ideal for navigation bars, button groups, card rows, sidebars and any layout where items need to share available space dynamically.

Container vs Item Properties

PropertyApplied toControls
display: flexContainerActivates the flex context on children
flex-directionContainerMain axis: row (horizontal) or column (vertical)
justify-contentContainerAlignment along the main axis
align-itemsContainerAlignment along the cross axis
flex-wrapContainerWhether items wrap to a new line
gapContainerSpace between flex items
flex-growItemHow much the item expands to fill space
flex-shrinkItemHow much the item contracts when space is tight
flex-basisItemDefault size before growing or shrinking
align-selfItemOverrides align-items for this item only

The flex Shorthand

flex: grow shrink basis — for example flex: 1 1 auto. The most common values:

  • flex: 1 — item grows to fill all available space equally with its siblings
  • flex: none — item keeps its natural size, does not grow or shrink
  • flex: 0 0 200px — fixed 200px wide, no growing or shrinking

Centering With Flexbox

The most common Flexbox use case is perfect centering — both horizontally and vertically in two lines:

.container {
  display: flex;
  justify-content: center;
  align-items: center;
}

Frequently Asked Questions