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 likeheight(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 withposition: fixed
orposition: absolute
.if the
main-container
is big (e.g. 1 page or more), then only a few margin should be added betweenmain-container
andfooter
(to the contrary of bullet point 1.)
How to do 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 be on bottom even if main-container has only 2 lines
</div>