css - Keeping HTML footer at the bottom of the window if page is short -
some of webpages short. in pages, footer might end in middle of window , below footer whitespace (in white). looks ugly. i'd footer @ bottom of window , limited content body gets stretched.
however, if webpage long , have scroll see footer (or of it), things should behave normal.
what's proper way css? need javascript/jquery make happen?
i care ie9+ , modern versions of other browsers. height of footer can change page page too, i'd not rely on height.
check out this site. has tutorial on how css.
i copied css in case matthew's site taken down.
html, body { margin:0; padding:0; height:100%; } #container { min-height:100%; position:relative; } #header { background:#ff0; padding:10px; } #body { padding:10px; padding-bottom:60px; /* height of footer */ } #footer { position:absolute; bottom:0; width:100%; height:60px; /* height of footer */ background:#6cf; } edit
since height of footer different page page, height of footer , adjust #body padding-bottom javascript. here example using jquery.
$(function(){ $('#body').css('padding-bottom', $('#footer').height()+'px'); });
Comments
Post a Comment