Let's say there are six divs on top of each other.
1st, 2nd and 3rd divisions have a fixed height, for example. 25px, 100px and 25px. The 4th div is the content area and should be an automatically custom div. The 5th div has some content, and the minimum height is 100 pixels (the height is NOT fixed). 6th div - the footer has a fixed height, for example. 25px.
The 5th and 6th div should always be at the bottom of the page (NOT sticky)
No problem if the 4th div (div_auto_height) has a lot of content and the page is also longer or longer than the screen.
The problem occurs when the page is shorter than the screen, and white space appears after the 6th div. Then the 5th and 6th divins are not where they were supposed to be.

The problem will be solved if you can automatically increase the height of the 4th div (div_auto_height) to fill the empty space.

I tried to solve this problem in different ways without a decent solution.
Broken solutions:
- There are different screen resolutions, so min-height does not work with large screens, without making the page very long for small or wide screens.
- I was not able to set the properties of the top and bottom positioning correctly because it makes divs 5 and 6 on top of the 4th div (div_auto_height)
Here is the template for your modification:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head><title>No title</title> <style type="text/css"> html { height: 100%; } body { height: 100%; margin: 0; } #div1 { height: 25px; background-color: #123456; } #div2 { height: 100px; background-color: #345678; } #div3 { height: 25px; background-color: #567890; } #div_auto_height { height: auto ; background-color: #789012; } #div5 { min-height: 100px; background-color: #901234; } #div6 { height: 25px; background-color: #123456; } </style> </head> <body> <div id="div1">Div 1</div> <div id="div2">Div 2</div> <div id="div3">Div 3</div> <div id="div_auto_height">This div should adjust automatically</div> <div id="div5">Div 5</div> <div id="div6">Div 6</div> </body> </html> </body> </html>
source share