UPDATE
Originally flagged as a duplicate, I mistakenly labeled it before actually testing the solution in the linked question. The provided answer did not meet my specific requirement of having a sticky footer that only floats to the bottom of the page when the content exceeds the viewport size.
/UPDATE
UPDATE2
I discovered a suitable solution on this website, which utilizes pure CSS and perfectly fulfills my needs.
/UPDATE2
I am looking for a way to keep the footer sticky until the document height surpasses the viewport height, at which point it should naturally align itself with the end of the document.
The structure of the document is as follows:
<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
, while the .footer
stands at 173px
.
The height of .page-content
varies based on the content within it.
My desired outcome is for the .footer
to remain fixed at the bottom of the viewport
unless the document
height exceeds that of the viewport
.
I attempted setting a min-height
for .page-content
to always overflow the viewport, but this resulted in an unattractive layout.
Is achieving this solely through CSS
possible, or would JavaScript
/JQuery
be necessary?