Created
August 19, 2013 20:49
-
-
Save michaelschofield/6274020 to your computer and use it in GitHub Desktop.
Sticky Footer
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, body { height: 100%; } | |
#container { | |
min-height: 100%; | |
margin-bottom: -12em; // Arbitrary. Must be the same as footer height. | |
&:after { | |
content: ""; | |
display: block; | |
} | |
} | |
.footer, #container:after { | |
height: 12em; | |
} | |
/* | |
I couldn't get this work, at first. | |
The thing is that you must wrap *all* content | |
except the footer in a container. I had originally | |
broken my HTML out into <header>, <div id="content">, and <footer>. | |
Applying the above just to #content doesn't work. Instead, it | |
requires the following structure: | |
<div id="container"> | |
<header></header> | |
<div id="content"></div> | |
</div> <!--/#container--> | |
<footer></footer> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment