Skip to content

Instantly share code, notes, and snippets.

@kcoyner
Created April 25, 2020 14:59
Show Gist options
  • Save kcoyner/e4dc5c94b1a4718b60872a79a4deb5a7 to your computer and use it in GitHub Desktop.
Save kcoyner/e4dc5c94b1a4718b60872a79a4deb5a7 to your computer and use it in GitHub Desktop.
Sticky Footer using Flexbox
<body>
<div class="content">
my content
</div>
<footer class="footer">
my footer
</footer>
</body>
html {
height: 100%;
}
body {
display: flex;
flex-direction: column;
height: 100vh; /* Avoid the IE 10-11 `min-height` bug. */
}
.content {
flex: 1 0 auto; /* Prevent Chrome, Opera, and Safari from letting these items shrink to smaller than their content's default minimum size. */
padding: 20px;
}
.footer {
flex-shrink: 0; /* Prevent Chrome, Opera, and Safari from letting these items shrink to smaller than their content's default minimum size. */
padding: 20px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment