Most flexbox layouts work by using the intrinsic sizing.
This means the sizes of boxes are determined by the size of the contents.
This is usually a good thing because you want your layout to stretch to the content, but also to the available space.
This makes layouts "flexible".
However sometimes you know you have content that will be larger than the surrounding container, and you need to perform overflow.
This happens quite often with <pre><code>...</code></pre>
content which can be
quite large.
So here we want to have a standard "sidebar" layout with grid items that will automatically resize to available space, and when space is scarce, it will first wrap the content where it can, and finally add scroll bars.
Got some ideas from:
To see the final layout: https://codepen.io/cmcdragonkai/pen/yLVXyZB
Notice the usage of 1em
as the gutter size between the main and sidebar.
This is used in 3 places .wrapper > *
, .wrapper > * > *
, and .main
.
The size of the side bar is to 300px
initially. If there is available space it
doesn't grow, but if there is less space it will squeeze down.
The side bar doesn't wrap because we don't use flex-wrap
. But that is possible
too.