I have the following HTML: http://jsfiddle.net/fMs67/. I’d like to make the div2 to respect the size of div1 and scroll the contents of div3.
Is this possible?
Thanks!
UPDATE-1:
This is the more advanced case that I oversimplified when I asked the question: http://jsfiddle.net/Wcgvt/. I need somehow that header+it’s sibling div to not overflow the parent div’s size.
Adding
position: relativeto the parent, and amax-height:100%; on div2 works.Update: The following shows the “updated” example and answer. http://jsfiddle.net/Wcgvt/181/
The secret there is to use
box-sizing: border-box, and some padding to make the second div height 100%, but move it’s content down 50px. Then wrap the content in a div withoverflow: autoto contain the scrollbar. Pay attention to z-indexes to keep all the text selectable – hope this helps, several years later.