CSS Flexbox

Flex basis

The flex-basis property specifies the base length along the main axis and is usually set to a length unit or auto. flex-basis has a higher priority than width or height (if set).

We usually set flex-basis to the minimum length we find acceptable for an element. If we set it to 100% and at the same time have flex-wrap set to wrap, we can force individual elements to take up an entire line creating neat stacks of elements. In the lesson about responsive design we use this feature to create mobile friendly layouts.

Read more on MDN

flex-basis

Test yourself

Description

Change the flex-basis of your .box <div> element to

100%

Notice how every box takes up an entire line after you've made the change. This combined with media queries makes it possible to easily create responsive layouts.

Tests

  1. 1 Your .box element should have flex basis set to 100%.
Editor
Preview