粘性页脚帮助! [英] Sticky Footer help!

查看:161
本文介绍了粘性页脚帮助!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的网页做一个粘性页脚,我发现一些CSS,确保页脚在底部,但有几个缺点。 1,如果你继续向下滚动页面,页面变得越来越大(这是完全意外,不知道是什么原因造成的)。 2它与页面一起在一个干扰的动作,如stop..go..stop..go。是否有任何调整或不同的代码,可能允许顺利移动粘滞页脚留在页面底部?

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?

顺便说一下,这段代码是oringaly

by the way, this code was oringaly for a static menu, I just adapted it for a sticky footer

这是JavaScript程式码,

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>

CSS:

.wireframemenu{
width: 99%;
height:60px;
position: absolute;
}


html>body .wireframemenu a{ /*Non IE rule*/
width: auto;
}

现在粘帖页:

<div id="staticmenu" class="wireframemenu" style="top: 520px;">
</div>


推荐答案

查看 CSS粘滞页脚实施问题

这篇关于粘性页脚帮助!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆