flexbox

align-items

Aligns flex or grid items along the cross axis of their container. It is the counterpart to justify-content and controls vertical alignment in a default row layout.

align-items: stretch | flex-start | flex-end | center | baseline | start | end

Common values

Value Effect
stretch Default; items fill the container's cross size
flex-start Aligns items to the start of the cross axis
center Centers items along the cross axis
flex-end Aligns items to the end of the cross axis
baseline Aligns items along their text baseline

Examples

.row { display: flex; align-items: center; }

Vertically centers children in a row

.cards { display: flex; align-items: stretch; }

All cards match the tallest sibling's height

.form { display: flex; align-items: baseline; }

Aligns label and input on their text baselines

Gotcha

stretch has no effect if items have an explicit height set; use align-self on individual items to override.

Related properties

← All CSS properties · CSS selectors · Grid vs Flexbox