

The most important thing to remember about flexbox sizing is that flex-grow doesn’t divide up the entire flex container, only the space that remains after the browser renders all flex items. The flex-grow property defines how any extra space in-between flex items should be allocated on the screen.

This also happens to be the default value of flex-direction, so I’ll use it in the following examples. The most common flex-direction used on left-to-right websites is row, which means you can allocate free space on the left-to-right axis. A reminder of how the main axis and the cross axis interact. If you need a refresher on how this works take a look at my tutorial about flexbox alignment. You can set the direction of the main axis using the flex-direction property. flex-basis: how flex items should behave when there’s exactly as much space as needed.Īs flexbox is a one-dimensional layout, as opposed to CSS Grid which is two-dimensional, you can allocate free space along the main axis (whether that be top to bottom, bottom to top, left to right, or right to left).flex-shrink: how flex items should behave when there’s a shortage of free space (how they should shrink).flex-grow: how flex items should behave when there’s a surplus of free space (how they should grow).At other viewport sizes, you might find there’s not enough space, and the layout breaks in one way or another.įlexbox’s sizing properties allow you to make decisions about three kinds of scenarios: At some viewport sizes, you’ll often find there’s too much remaining space and you want to fill it with something.

FONT BOX STAYS THE SAME SIZE CSS HOW TO
One of the most challenging aspects of writing CSS is figuring out how to allocate the free space that remains on the screen after the page has been populated with content.
