Reputation: 34207
How to make a div overflow when it is larger than its container when height cannot be specified?
Prerequisites:
.Wrap
is variable in height and cannot have a set height
..Head
should be a fixed height..Body
should become sccrollable when it is larger in height than its
container (.Wrap
)The plan here is to make .Body
stretch to fit .Wrap
causing overflow
to trigger.
CURRENT CSS
.Wrap{
position:fixed;
top:10%;
left:10%;
display:flex wrap;
align-items:stretch;
max-height:50%;
max-width:50%;
overflow:hidden;
}
.Head{
height:50px;
width:100%;
}
.Body{
overflow:auto;
}
Upvotes: 0
Views: 146
Reputation: 66123
You can try specifying a min-height
for .Head
(to prevent flexbox from forcibly collapsing it), and set the flex-flow property of the parent .Wrap
element to column nowrap
:
.Wrap{
position:fixed;
top:10%;
left:10%;
display:flex;
flex-flow: column nowrap;
align-items:stretch;
background:#ddd;
max-height:50%;
max-width:50%;
padding:10px;
overflow:hidden;
}
.Head{
background:#e00;
height:50px;
min-height: 50px;
width:100%;
}
Upvotes: 1