I might be missing something very basic here, but I cannot find how to control overflow with Flexbox.
Is there a way to make sure a flex container will not be bigger than its flex parent, despite any big image/list/... ?
I cannot reproduce my exact case but the case below shows how a picture can wreak some havoc and I did not succeed with max-width
/max-height
or overflow
.
.parent {
border: dotted 1px red;
display: flex;
max-height: 50px;
}
.content {
border: solid 1px blue;
display: flex;
flex: 1 1 auto;
}
.menu {
flex-grow: 0;
flex-direction: column;
overflow-y: scroll;
}
.large {
flex-grow: 3
}
<div class="parent">
<div class="content menu">
<div>
some header
</div>
<div>
<ul>
<li>
<img src="https://css-tricks.com/wp-content/uploads/2014/05/flex-container.svg" />
</li>
<li>item2</li>
<li>item3</li>
<li>item4</li>
<li>item5</li>
<li>item6</li>
<li>item7</li>
<li>item8</li>
<li>item9</li>
</ul>
</div>
</div>
<div class="content large">
the content
</div>
<div class="content">
ads
</div>
</div>
I know the correct solution would be to rewrite all the flexbox structure of the app (a bit of legacy, quickly done work and so on), but this will have to wait as we are quite in a rush right now.
My own case
Edit: here is the case that's troubling me. I cannot reproduce the whole structure quickly in a fiddle, but you may get the gist from my previous try at it.
Expected
This is how my layout should look like and how it does look like once I've removed all problematic <li>
from the left column.
Actual
The left column is an unordered list. The content of some <li>
may grow too long, resulting in the left menu getting bigger and spreading over what should be a margin.
In one case, we have an (wide) image in the <li>
. The whole parent is then widened, beyond the screen, with no possibility to scroll. The action buttons we should have on the right of the title bar would be inaccessible.
CSS SitRep
We have overflow: hidden
rules on all the <li>
and <div>
inside the list and flex-basis: 0
for each container.