I have a container <div>
with a specified height, and contained within are two more DIVs, on for introductory copy that will vary (entered by the client), and another to list out various features.
I want the features <div>
to automatically fill the remaining space in the parent, and then scroll out the overflow.
How do I do that?
CSS:
#article {
width:940px;
height:500px
}
#article-content {
margin: 20px 0;
}
#article-features {
height:100%;
overflow-x: auto;
}
jsFiddle
Using height: auto or using min-height on parent element will work. And for avoiding horizontal scrollbar, which can be caused due to padding or border can be avoided by using box-sizing: border-box on child element or overflow: hidden on parent element.
No way to do it with HTML4 other than relying on javascript to dynamically change the height of the bottom div based upon calculation (parent_height - sibling_height).
You may look at this: CSS HTML - DIV height fill remaining space
With HTML5 you may use Flexbox to use the remaining space. Note that there are some limitations but it can answer your requirements. See http://caniuse.com/#feat=flexbox.
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