I have this kind of structure, where I am wrapping three divs (top, middle, bottom) inside a div (wrapper):
#wrapper {
width: 60%;
height: 200px;
border: 2px solid red;
margin: 0 auto;
position: relative;
}
#top {
height: 50px;
background: green;
}
#middle {
background: orange;
overflow: auto;
}
#bottom {
background: blue;
position: absolute;
width: 100%;
bottom: 0;
left: 0;
padding: 10px 0;
}
<html>
<body>
<div id="wrapper">
<div id="top">
Top
</div>
<div id="middle">
<ul>
<li>Some content</li>
<li>Some content</li>
<li>Some content</li>
<li>Some content</li>
<li>Some content</li>
<li>Some content</li>
<li>Some content</li>
<li>Some content</li>
<li>Some content</li>
</ul>
</div>
<div id="bottom">
Bottom
</div>
</div>
</body>
</html>
As you can see the wrapper div has a fixed height, and the bottom div is positioned absolute in relation to the wrapper div. And the middle div has a list of contents, which is are out of the wrapper div. What I want to achieve is to make the middle div take only the remaining height is between the top div and the bottom div and still be able to scroll. How can I achieve this?