Revision 3:
In my revised solution, I have incorporated CSS as a fallback option from the previous edit but added JavaScript functionality to dynamically resize div elements upon page load and window size changes. This combination ensures a visually appealing layout even if JavaScript is disabled. The JS code snippet can be found below, and you can view a live demo on this link.
var resizeDiv = function(){
document.getElementById('c').style.height = getWindowHeight() - 64 + 'px';
};
//Reusable method
var getWindowHeight = function(){
if (window.innerHeight) {
return window.innerHeight;
}
if (document.body && document.body.offsetHeight) {
return document.body.offsetHeight;
}
if (document.compatMode=='CSS1Compat' &&
document.documentElement &&
document.documentElement.offsetHeight ) {
return document.documentElement.offsetHeight;
}
return 740;//default height value
};
//Initiate resizing on pageload
window.onresize = resizeDiv;
setTimeout(resizeDiv);
To address your specific issue with the third div's height, I recommend setting it to take up the remaining space using absolute or percentage values, ensuring overflow is hidden on the parent container, allowing inner content to dictate scrollbar presence. Check out an updated fiddle demonstrating this aspect here.
Update:
Considering your mention of "Imagine the container is the browser", adjusting overflow to 'scroll' and setting the third div's height to 'auto' ought to display the scrollbar correctly inside the main container. See the modified example in action here.
Further Edit #2:
Based on your feedback regarding the percentage approach, utilizing percentage heights for all sections seems suitable. However, keep in mind the limitations mentioned regarding fixed vs. dynamic content placement. Another alternative involves setting a minimum window size and adjusting the third element's percentage accordingly. Here is a suggested implementation here. For optimal results, consider incorporating event listeners to adjust div sizes dynamically upon window resize.
Note: A blend of percentage and pixel units for sizing properties would simplify these scenarios immensely!