FlexPlay

Interactive CSS Flexbox Playground & Cheatsheet

Container Properties
Main axis direction for item layout
Whether items wrap to new lines
Alignment along the main axis
Alignment along the cross axis
Multi-line cross-axis alignment (needs wrap)
10px
Item Properties

Click an item in the preview to select it, then adjust its properties below.

0
How much the item grows relative to siblings
1
How much the item shrinks when space is tight
Initial main size before grow/shrink
0
Visual ordering (lower appears first)
Override container's align-items for this item
Presets
Live Preview
Flexbox Cheatsheet
Container Properties
display: flexCreates a flex container
flex-directionrow | row-reverse | column | column-reverse
flex-wrapnowrap | wrap | wrap-reverse
justify-contentflex-start | flex-end | center | space-between | space-around | space-evenly
align-itemsstretch | flex-start | flex-end | center | baseline
align-contentnormal | flex-start | flex-end | center | space-between | space-around | stretch
gapSets spacing between items (row-gap, column-gap)
Item Properties
flex-grow0 = no grow; 1+ = fills available space proportionally
flex-shrink1 = can shrink; 0 = won't shrink below basis
flex-basisInitial size before growing/shrinking (auto, px, %)
orderInteger controlling visual order (default 0)
align-selfOverrides align-items for a single item
Shorthand
flex: 1flex-grow: 1; flex-shrink: 1; flex-basis: 0%
flex: autoflex-grow: 1; flex-shrink: 1; flex-basis: auto
flex: noneflex-grow: 0; flex-shrink: 0; flex-basis: auto
flex: 0 1 200pxNo grow, can shrink, starts at 200px
Generated CSS