23 Feb, 2009

Footer altijd onderaan scherm

Categoriën: crossbrowser |Footer |IE6 |IE7 |solution |template |valid |Xhtml Strict

Deze methode is ook bekend als “Sticky Footer” en heeft als doel dat de footer altijd onder aan het scherm “hangt/plakt” ongeacht de inhoud. Dus bij weinig inhoud (geen scrollbars) staat de footer onderaan.

HTML

<div id="wrap">
<div id="main" class="clearfix">
<p>content</p>
</div>
</div>
<div id="footer">
 <p>content</p>
</div>

CSS

* {margin:0;padding:0;}
/* must declare 0 margins on everything,
also for main layout components use padding,
not vertical margins (top and bottom) to add spacing,
else those margins get added to total height
and your footer gets pushed down a bit more,
creating vertical scroll bars in the browser */
html, body, #wrap {
height: 100%;
}
body > #wrap {
height: auto;
min-height: 100%;
}
#main {
padding-bottom: 150px; /* must be same height as the footer */
}
#footer {
position: relative;
margin-top: -150px; /* negative value of footer height */
height: 150px;
clear:both;
}
/* CLEAR FIX*/
.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.clearfix {
display: inline-block;
}
/* Hides from IE-mac \*/
* html .clearfix { height: 1%;}
.clearfix {display: block;}
/* End hide from IE-mac */

Gerelateerde Snippets

Geen reacties op "Footer altijd onderaan scherm"

Reactie formulier


Demo: Footer altijd onderaan scherm:

Advertenties

Volgende nieuwe Snippet:

  • Momenteel niks gepland.