Skip to content

Instantly share code, notes, and snippets.

@stanwmusic
Created February 21, 2026 03:20
Show Gist options
  • Select an option

  • Save stanwmusic/9f63b038edc6ffc1af720d0de8bcb3f4 to your computer and use it in GitHub Desktop.

Select an option

Save stanwmusic/9f63b038edc6ffc1af720d0de8bcb3f4 to your computer and use it in GitHub Desktop.
Sticky Footer
<div class="page-wrap">
<h1>Sticky Footer</h1>
<h2>with Fixed Footer Height</h2>
<button id="add">Add Content</button>
</div>
<footer class="site-footer">
I'm a Sticky Footer.
</footer>
$("#add").on("click", function () {
$("<p>P</p><h2>H2</h2><h1>H1</h1>").appendTo(".page-wrap");
});
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
/* Mostly: http://ryanfait.com/sticky-footer/ */
* {
margin: 0;
}
html,
body {
height: 100%;
}
.page-wrap {
min-height: 100%;
/* equal to footer height */
margin-bottom: -142px;
}
.page-wrap:after {
content: "";
display: block;
}
.site-footer,
.page-wrap:after {
/* .push must be the same height as footer */
height: 142px;
}
.site-footer {
background: orange;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment