CSS Flexbox

Flex wrap

The flex-wrap property is used to specify whether flexible elements are allowed to wrap to multiple lines or should be forced to stay on one line.

nowrap is the default value and forces the flexible elements to be laid out in a single line and may cause overflow.

wrap allows the elements to break into multiple lines.

If we leave the default nowrap, flex elements will shrink as much as necessary/possible in order to not create overflow. The amount of shrinking can be controlled with flex-shrink.

Read more on MDN

flex-wrap

Test yourself

Description

Change the flex-wrap of your .wrapper <div> element to

wrap

Notice how the boxes have shrunk in order to fit on the same line, and jump on the opportunity to expand to their original widths of 100px after you've made the change.

Tests

  1. 1 Your .wrapper element should have flex wrap set to wrap.
Editor
Preview