Container Properties (Parent)

.container { display: flex; /* or inline-flex */ }
PropertyValuesDescription
flex-directionrow | row-reverse | column | column-reverseDirection of main axis
flex-wrapnowrap | wrap | wrap-reverseWhether items wrap to next line
flex-flow[direction] [wrap]Shorthand for direction + wrap
justify-contentflex-start | flex-end | center | space-between | space-around | space-evenlyAlign along main axis
align-itemsstretch | flex-start | flex-end | center | baselineAlign along cross axis
align-contentSame as justify-content + stretchAlign rows when there's extra space (multi-line only)
gappx / rem / %Space between items (row-gap column-gap)

Item Properties (Children)

PropertyDefaultDescription
flex-grow0How much item grows to fill available space (ratio)
flex-shrink1How much item shrinks when container is too small
flex-basisautoDefault size before grow/shrink are applied
align-selfautoOverride container's align-items for this item
order0Visual order — lower numbers appear first

flex Shorthand

/* flex: grow shrink basis */
flex: 1;          /* flex: 1 1 0% — grow and shrink equally */
flex: auto;       /* flex: 1 1 auto */
flex: none;       /* flex: 0 0 auto — rigid, won't grow or shrink */
flex: 0 0 200px;  /* exactly 200px, won't flex */
flex: 2;          /* grows twice as fast as flex:1 siblings */

Common Patterns

/* Horizontal nav with spacer */
.nav { display: flex; align-items: center; }
.nav .spacer { flex: 1; }  /* pushes right items to end */

/* Equal height columns */
.columns { display: flex; gap: 20px; }
.column { flex: 1; }  /* all columns same width */

/* Center everything */
.hero { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

/* Card grid that wraps */
.cards { display: flex; flex-wrap: wrap; gap: 16px; }
.card { flex: 1 1 280px; }  /* min 280px, grows to fill */

/* Sidebar layout */
.layout { display: flex; gap: 32px; }
.sidebar { flex: 0 0 260px; }  /* fixed 260px */
.main { flex: 1; }             /* fills the rest */