Back to Home
Published: June 2026By Web Util Slyce Team8 min read

CSS Flexbox — Complete Reference

A complete guide to CSS Flexbox. Generate layouts visually with our Flexbox Generator.

Flex Container Properties

PropertyValuesDescription
displayflex, inline-flexDefines a flex container
flex-directionrow, row-reverse, column, column-reverseSets the main axis direction
flex-wrapnowrap, wrap, wrap-reverseControls item wrapping
justify-contentflex-start, flex-end, center, space-between, space-around, space-evenlyAligns items along the main axis
align-itemsstretch, flex-start, flex-end, center, baselineAligns items along the cross axis
align-contentstretch, flex-start, flex-end, center, space-between, space-aroundAligns multi-line content along cross axis
gap10px, 1rem, etc.Gap between flex items (row-gap + column-gap shorthand)

Flex Item Properties

PropertyValuesDescription
flex-grow0 (default), 1, any numberAbility to grow relative to siblings
flex-shrink1 (default), 0, any numberAbility to shrink relative to siblings
flex-basisauto, 0, 200px, etc.Initial size before growing/shrinking
flex0 1 auto (shorthand)Shorthand for grow, shrink, basis
align-selfauto, stretch, flex-start, flex-end, center, baselineOverrides align-items for this item
order0 (default), any integerControls the visual order of items

Common Flexbox Patterns

Centering

display: flex; justify-content: center; align-items: center;

Perfectly centers child elements both horizontally and vertically

Equal columns

display: flex; > * { flex: 1; }

Distributes space equally among all flex children

Sticky footer

display: flex; flex-direction: column; main { flex: 1; }

Pushes footer to bottom when content is short

Holy Grail layout

display: flex; flex-wrap: wrap; nav { flex: 0 0 200px; } main { flex: 1; } aside { flex: 0 0 150px; }

Header + nav/main/aside + footer layout

Auto margins

display: flex; .push-right { margin-left: auto; }

Pushes an item to the right edge using auto margin