flexbox

justify-content

Aligns flex or grid items along the main axis, distributing extra space between them. It has no effect if the items already fill the container.

justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly | start | end

Common values

Value Effect
flex-start Packs items to the start of the main axis
center Centers items along the main axis
flex-end Packs items to the end of the main axis
space-between Equal space between items, none at edges
space-around Equal space around each item
space-evenly Equal space between items and at edges

Examples

.nav { display: flex; justify-content: space-between; }

Logo left, actions right

.center { display: flex; justify-content: center; }

Horizontally centers children

.toolbar { display: flex; justify-content: flex-end; }

Buttons pinned to the right

Gotcha

In a column flex container this aligns vertically; use align-items for the cross axis instead.

Related properties

← All CSS properties · CSS selectors · Grid vs Flexbox