I'm currently working on designing a webpage that includes three separate divs: a header, a footer, and a content area. These divs are intended to fill up the entire screen space available.
The header and footer remain consistent in size and structure, while the content area is flexible and can vary in length. To address this, I have applied the CSS property overflow:auto
to allow for scrolling when the content surpasses a certain length.
However, the issue arises when the content area extends beyond the screen height. I have created a demonstration using a fiddle: https://jsfiddle.net/tdxn1e7p/
To ensure the height of the html and body elements are set to 100%, I utilize the following CSS code, enabling the use of height:100%
on the container element:
html,
body {
height: 100%;
}
The layout of my document follows this structure:
<div style="height:100%;">
<div>
Header content
</div>
<div style="overflow:auto;">
Body content... which may vary in length
</div>
<div>
Footer content
</div>
</div>
While I've come across various solutions to similar issues, such as this question, I have yet to find a resolution that works effectively for my specific case.