<div id="main-container" contentEditable>
Hello<br>
World
</div>
<div id="footer">
Bye-bye.
</div>
Problem :
I would like to have a footer:
at the bottom of the page, even if the main-container is very short in height, e.g. only 300px high. In this case a big vertical margin should be added.
Probably of something like height(viewport) - height(main-container) - height(header)
in the normal flow of the body, after <div id="main-container">, so I don’t want to place it with position: fixed or position: absolute.
if the main-container is big (e.g. 1 page or more), then only a few margin should be added between main-container and footer (to the contrary of bullet point 1.)
<div id="header">Header</div>
<div id="main-container">
Hello<br>
World
</div>
<div id="footer">
Bye-bye. <-- this should be on bottom even if main-container has only 2 lines
</div>
Comments
Comment posted by CSS to make HTML page footer stay at bottom of the page with a minimum height, but not overlap the page
Does this answer your question?
Comment posted by Basj
Perfect! I added
Comment posted by Basj
Thank you, but this doesn’t work if main-container grows in height: try, you will see an overlap.