EDIT
Incorrectly marked as a duplicate, I marked it duplicate before I tested the answer on the referred question. It doesn't provide the exactly what I want, which is a sticky footer initially and only float to the bottom of the page when the content is larger than the viewport.
/EDIT
EDIT2
Found the answer over here, pure CSS and does exactly what I want.
/EDIT2
I want a sticky footer until the document height is greater than the viewport height, then it just should be at the end of the document.
The document is build up like this:
<body>
<div class="header">
<!-- content -->
</div>
<div class="page-content">
<!-- content -->
</div>
<div class="footer">
<!-- content -->
</div>
</body>
The .header
has a height of 101px
and .footer
has a height of 173px
.
.page-content
has a variable height depending on the content.
What I want is for .footer
to stick to the bottom of the viewport
as long as .page-content
doesn't contain enough content for the document
to have a greater height than the viewport
I tried giving .page-content
a min-hieght
so it always overflows the viewport but that is just plain ugly.
Is this possible pure CSS
or does Javascript
/JQuery
come in to play here?