My approach to solving this issue is as follows:
.page {
background-color: #8f8;
min-height: 100%;
width: 80%;
}
.header {
background-color: #fdc;
overflow: hidden;
}
.content {
background-color: #ccf;
overflow-y: auto;
height: 100%;
width: 100%;
/*word-wrap: break-word;*/
}
Here's what I've implemented:
- For the Page section, setting a minimum height of 100% allows it to fill up all available space rather than specifying a fixed height.
- The Header section needs its overflow set to hidden in order to resize properly when content changes. It should also be displayed as a block element to work correctly.
- In the Content section, the height is set to 100% to utilize all available space. Vertical scrolling will only appear when necessary and word wrapping may be enabled based on content requirements.
To prevent the page from extending beyond the bottom, consider incorporating the header within the content div.
Feel free to reach out for further clarifications.
UPDATE: An example demonstrating the solution can be accessed here.
UPDATE2
An improved version of the solution can be viewed here:
.page {
background-color: #ccf;
max-height: 100%;
width: 80%;
overflow: hidden;
}
.header {
background-color: #fdc;
overflow: hidden;
}
.content{
overflow-y: auto;
height: 100%;
word-wrap: break-word;
}
An issue with this setup is that the scroll functionality treats the entire "page" as scrollable instead of just the content area, resulting in incomplete visibility.
A potential JavaScript solution is provided below:
$(window).resize(function() {
resizeContent();
});
$(document).load(function(){
resizeContent();
});
function resizeContent(){
$('.content').height($(".page").height()-$('.header').height());
}
For the finalized solution, refer to this link