I'd like to make a flexbox where:
- Items are arranged in columns
- As long as all items will fit within a fixed width, wrapping creates more columns.
- If the items need more space, the flexbox grows vertically after that, with a vertical scrollbar rather than a horizontal one.
Is there any way to achieve this without Javascript?
The following does the right thing until there are too many items, but then it overflows horizontally rather than vertically.
<div style="height: 100%; width: 100%; overflow-y: auto;">
<div style="display: flex; flex-direction: column; flex-wrap: wrap; width: 100%; height: 100%; overflow-y: auto">
<div style="width: 15em;"> a </div>
<div style="width: 15em;"> b </div>
<div style="width: 15em;"> c </div>
<div style="width: 15em;"> d </div>
<div style="width: 15em;"> e </div>
<div style="width: 15em;"> f </div>
<div style="width: 15em;"> g </div>
<div style="width: 15em;"> h </div>
<div style="width: 15em;"> i </div>
<div style="width: 15em;"> j </div>
<div style="width: 15em;"> k </div>
<div style="width: 15em;"> l </div>
<div style="width: 15em;"> m </div>
<div style="width: 15em;"> n </div>
<div style="width: 15em;"> o </div>
<div style="width: 15em;"> p </div>
<div style="width: 15em;"> q </div>
<div style="width: 15em;"> r </div>
<div style="width: 15em;"> s </div>
<div style="width: 15em;"> t </div>
<div style="width: 15em;"> u </div>
</div>
</div>