I am trying to make a sticky footer for my web page, I found some CSS that does keep the footer at the bottom but has a few downsides. 1, If you keep scrolling down the page the page just gets bigger and bigger (that was completely unexpected, no idea what caused that). 2 it moves down with the page in a jerky action, like stop..go..stop..go. Are there any tweaks or different code that might allow a smooth moving sticky footer to stay at the bottom of the page?
by the way, this code was oringaly for a static menu, I just adapted it for a sticky footer
Here's the javascript code,
<script type="text/javascript">
// attribute added inline inside tag)
var staticmenuids=["staticmenu"]
var staticmenuoffsetY=[]
function getmenuoffsetY(){
for (var i=0; i<staticmenuids.length; i++){
var currentmenu=document.getElementById(staticmenuids[i])
staticmenuoffsetY.push(isNaN(parseInt(currentmenu.style.top))? 0 :
parseInt(currentmenu.style.top))
}
initstaticmenu()
}
function initstaticmenu(){
var iebody=(document.compatMode &&
document.compatMode!="BackCompat")?
document.documentElement : document.body
var topcorner=(window.pageYOffset)? window.pageYOffset : iebody.scrollTop
for (var i=0; i<staticmenuids.length; i++)
document.getElementById(staticmenuids[i]).style.top=topcorner+staticmenuoffsetY[i]+"px");
setTimeout("initstaticmenu()", 5)
}
if (window.addEventListener)
window.addEventListener("load", getmenuoffsetY, false)
else if (window.attachEvent)
window.attachEvent("onload", getmenuoffsetY)
</script>
The CSS:
.wireframemenu{
width: 99%;
height:60px;
position: absolute;
}
html>body .wireframemenu a{ /*Non IE rule*/
width: auto;
}
Now the sticky footer:
<div id="staticmenu" class="wireframemenu" style="top: 520px;">
</div>