What I have is a simple structure of container
followed by two child elements, content
and footer
.
footer
has a fixed height and content
should fill remaining empty space. That is easy enough to achieve with display:table;
but for some reason I can't figure out how to make content
element overflow to work if its contents exceed website window height?
Here is a JSFiddle, if you set content_child
height to say 10px
you can see content
element filling up the space nicely but when content_child
is a lot bigger content
element shouldn't expand the way it does now, what am i missing here?
I would prefer to not use JavaScript to solve this if possible.
body, html{
height: 100%;
padding: 0px;
margin: 0px;
}
.container{
display:table;
background; black;
width: 100%;
background: black;
height: 100%;
}
.top{
background: blue;
display:table-row;
height: 100%;
}
.bottom{
background: red;
height: 60px;
}
.content{
height: 100%;
overflow: hidden;
padding: 5px;
}
.content_child{
height: 1000px;
background: grey;
}
<div class="container">
<div class="top">
<div class="content">
<div class="content_child"></div>
</div>
</div>
</div>
<div class="bottom">
</div>
</div>