HomeGuideLabGlossary

aligns and distributes flex lines in the cross direction

You saw : stretch applied to flex lines in the previous chapter. This was done during the Sizing phase of Flexbox layout, because if you stretch flex lines and then you stretch flex items, you’re changing the size of the flex items.

Cross directionalign-content: stretch

In the Alignment phase, the other values of are applied if you have a multi-line flex container. If you have a single-line flex container (the default : nowrap situation), then the single flex line is the exact same size as the flex container, so there’s nothing for to do.

flex-wrap: nowrapalign-contentDOES NOTHINGThe single flex line is the same size as the flex container

is just like , with three differences.

Difference One: works on flex lines, works on flex items.

Think of it as having a container in which you’ll align and distribute items.

In both cases, our container is the content box of the flex container.

FLEX CONTAINER=ALIGNMENT CONTAINER

Think of the things you’re aligning or distributing as alignment subjects.

With , the flex items are our alignment subjects.

12justify-contentFLEX ITEMS=ALIGNMENT SUBJECTS

With , the flex lines are our alignment subjects.

FLEX LINES=ALIGNMENT SUBJECTSalign-content

Difference Two: You can stretch flex lines, but you can’t stretch flex items.

That’s because works in the main axis.

Stretching flex items would mean changing their size in the main axis.

Because flex items have complete control over their sizing along the main axis in Flexbox, you can’t stretch them.

align-content: stretchjustify-content: stretch1Totally fineThe stretching along the main axis is done by flex itemsflex-grow: 1

Difference Three: is always applied, is only applied if the flex container is multi-line.

The flex container is considered multi-line if it has : wrap or : wrap-reverse.

flex-wrap: nowrapflex-wrap: wrapflex-wrap: wrap-reverseSINGLE-LINEMULTI-LINE

Stretching values are applied in the Sizing phase.

You already saw a description of this in a previous chapter.

Alignment and distribution values are applied at the very end of the Alignment phase.

This is done after flex items and flex lines have been sized (the Sizing phase).

132Flex items sized and aligned, now we can align and distribute flex linesCross direction