Created
April 25, 2020 14:59
-
-
Save kcoyner/e4dc5c94b1a4718b60872a79a4deb5a7 to your computer and use it in GitHub Desktop.
Sticky Footer using Flexbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<div class="content"> | |
my content | |
</div> | |
<footer class="footer"> | |
my footer | |
</footer> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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