RUNWEBTOOLS
English

CSS Flexbox Cheat Sheet: Properties and Values

Flexbox lays out items in one dimension — a row or a column — and distributes space between them. Properties split into two groups: those you set on the container (the flex parent) and those you set on the items (its children).

The mental model: flex-direction sets the main axis; justify-content aligns along it, and align-items aligns along the perpendicular cross axis.

Updated 2026-07-06

Container properties (the flex parent)

PropertyValuesWhat it does
displayflex | inline-flexTurn an element into a flex container
flex-directionrow | row-reverse | column | column-reverseMain axis direction
flex-wrapnowrap | wrap | wrap-reverseWhether items wrap onto new lines
justify-contentflex-start | center | flex-end | space-between | space-around | space-evenlyAlignment along the main axis
align-itemsstretch | flex-start | center | flex-end | baselineAlignment along the cross axis
align-contentflex-start | center | space-between | stretchAligns wrapped lines (multi-row)
gap<length> (e.g. 16px)Space between items

Item properties (the children)

PropertyValuesWhat it does
flex-grow0 | <number>How much an item grows to fill space
flex-shrink1 | <number>How much an item shrinks when space is tight
flex-basisauto | <length>The item's starting size before grow/shrink
flexe.g. 1 1 0 | 1 | autoShorthand for grow, shrink, and basis
align-selfauto | center | flex-start | flex-end | stretchOverride align-items for one item
order0 | <integer>Reorder an item visually (lower comes first)

The most common centering trick: on the container, set display: flex; justify-content: center; align-items: center; to center a child both horizontally and vertically. For sizing units used in these values, see the CSS units reference.