I need to place a footer
on my webpage in a specific way:
It should be at the bottom of the page, even if the content in the
main-container
is short. In this case, a large vertical margin needs to be added that calculates as
.height(viewport) - height(main-container) - height(header)
The footer needs to be within the normal flow of the body, appearing after the
<div id="main-container">
, without usingposition: fixed
orposition: absolute
.If the main content in the
main-container
is lengthy (more than one page), then only a small margin should separate themain-container
and thefooter
(opposite to the first point).
How can I achieve this?
#header { background-color: yellow; }
#main-container { background-color: red; }
#footer { background-color: green; }
<div id="header">Header</div>
<div id="main-container">
Hello<br>
World
</div>
<div id="footer">
Bye-bye. <-- this should stay at the bottom even if main-container has minimal content
</div>