固定页脚移动浏览器的位置

时间:2010-12-01 12:12:28

标签: javascript css footer

美好的一天,我有一个这样的元

<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalabale=no, width=device-width, height=device-height" />

现在我可以使用js获取高度视图端口 我想用它来修改我的页脚,所以它使用固定的定位始终位于屏幕的底部。这是页脚css

#footer
{
height:30px;
background-color:#D9D9D9;
background-image:url(../images/footer.png);
background-repeat:repeat-x;
margin-top:20px;
width:100%;
/*bottom:0;
position:fixed;*/
}

如何使用JS修改此页脚以获得正确的内容。谢谢。 @cyberomin。

4 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

document.getElementById("footer").style.position = "fixed";

答案 2 :(得分:0)

如果您通过移动浏览器表示“移动游侠”,那么您运气不佳,则不支持定位。

相关答案:Fixed positioning in Mobile Safari

编辑:此项目可能对您有所帮助 - &gt; http://cubiq.org/iscroll

答案 3 :(得分:0)

自Android 2.2起,该位置已修复。

但是对于像iPhone这样的其他设备,您必须拥有一个模拟原生卷轴的解决方案:这种类型的解决方案可通过JavaScript工具包 Wink 获得。此工具包允许轻松制作WebApp,同时保持简单易用(无需学习API)。查看Scroller组件上的示例。

相关问题