HomeGuideLabGlossary

Suggesting stretch to flex items with : stretch

Before sizing flex items is done, the flex container gets to make a suggestion

The flex container can suggest to flex items that they should stretch themselves or align themselves in a particular way in their flex line along the cross axis.

align-items: centeralign-items: stretch

This happens after the flex items have gone through an initial round of sizing.

1We know this sizeit won’t change anymoreAny growing in this direction is already doneWe have an initial idea for this size, but it might still get stretched

And after the flex lines have potentially stretched if the flex container is multi-line.

12We stretched alreadyWe haven’t yet

The default value of normal means stretch

The property is used differently in different layout types.

align-items: normal

normal could mean something else in another layout type.

?align-items: normalIN SOME OTHER TYPE OF LAYOUT

In Flexbox, normal means stretch.

IN FLEXBOXalign-items: stretchalign-items: normal

It’s a suggestion because only has an effect on flex items that will “listen”.

Flex items always have a final say.

No, thank you!Stretch, please?1align-items: stretch

Whether or not a particular flex item will “listen” depends on its value of align-self.

1align-self: center

So each flex item looks at its value of align-self first.

align-self1?

By default, the value is auto, which means “I’ll size or position myself according to the value of the flex container’s property”.

1align-self: autoOkay fine, how did you want flex items to align themselves?!align-items: stretch

By default, flex items have align-self: auto and the flex container suggests stretching

So if you have a multi-line flex container (that is, is not nowrap), then flex items will stretch themselves in their flex line along the cross axis.

12By default, flex containers suggest stretching and flex items listen