My issue is probably best explained by example. This following jsfiddle will work in Chrome:
http://jsfiddle.net/ga6g4/
As you can see, I've got a fixed-height flexbox with a fixed header and a scrollable body. So far so good. However, if you change the 'height' CSS of the '.lhs' container to max-height:
max-height: 100px;
http://jsfiddle.net/ga6g4/1/
It breaks. It seems to now think that my list is now zero-height! Any idea why this is doing what it is doing, and how I can fix it?
EDIT: I wasn't descriptive enough in my original post in how I want this to behave. Basically the outer should use only the minimum height it requires, but only up to a maximum (defined by max-height). At this point, I want the content to begin scrolling.
Getting the child of a flex-item to fill height 100%Set position: absolute; on the child. You can then set width/height as required (100% in my sample).
Explanation: min-width in a flex context: While the default min-width value is 0 (zero), for flex items it is auto . This can make block elements take up much more space than desired, resulting in overflow.
It can be changed by using the flex-direction property. To use flexbox, we have to set display: flex or inline-flex to flex-container. By default, the height and width of a flex-container are set to auto. But we can define a fixed amount to them.
A flexbox item can be set to a fixed width by setting 3 CSS properties — flex-basis, flex-grow & flex-shrink. flex-basis : This property specifies the initial length of the flex item. flex-grow : This property specifies how much the flex item will grow relative to the rest of the flex items.
OK, here's the solution I ended up with if anyone is interested:
http://jsfiddle.net/vN65r/
Basically, I had to apply the following to the fixed-height header:
flex: 0 0 auto;
And the following to the variable-height, scrolling body:
flex: 0 1 auto;
I hope it helps somebody
Giving it both max-height:100px;
and height:100%;
should work. http://jsfiddle.net/ga6g4/2/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With