I would like to have a footer:
at the bottom of the page, even if the
main-containeris 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: fixedorposition: absolute.if the
main-containeris big (e.g. 1 page or more), then only a few margin should be added betweenmain-containerandfooter(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>