Skip to content

Instantly share code, notes, and snippets.

@RutledgePaulV
Created March 21, 2014 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RutledgePaulV/9682500 to your computer and use it in GitHub Desktop.
Save RutledgePaulV/9682500 to your computer and use it in GitHub Desktop.
This little mixin handles everything necessary to get a 'sticky' footer. Simply pass in the selectors for the DOM elements as described below.
.force-height(@height: 100%) {
height: @height;
min-height: @height;
}
.apply(@selector: ~'', @contents){
@{selector}{
@contents();
}
}
.sticky-footer(@wrap:~'#wrap',
@content-wrap:~'#content-wrap',
@footer-push:~'#footer-push',
@footer-wrap:~'#footer-wrap',
@height: 100px, @buffer: 25px) {
@wrap-rules:{
.force-height();
};
@content-wrap-rules:{
min-height: 100%;
height: auto !important;
margin-bottom: -@height;
};
@footer-push-rules:{
.force-height(@height);
};
@footer-wrap-rules:{
padding-top: @buffer;
margin-top: @buffer;
.force-height(@height - @buffer);
};
.apply(@wrap,@wrap-rules);
.apply(@content-wrap, @content-wrap-rules);
.apply(@footer-push, @footer-push-rules);
.apply(@footer-wrap, @footer-wrap-rules);
}
@RutledgePaulV
Copy link
Author

<div id='wrap'>

     <div id='content-wrap'>

        <div id='header-wrap'></div>

        <div id='body-wrap'></div>

        <div id='footer-push'></div>

    </div>

    <div id='footer-wrap'></div>

 </div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment