如何将页脚固定在页面底部

来源:互联网 发布:腾讯模拟炒股软件 编辑:程序博客网 时间:2024/05/21 09:53

参考文档:http://www.kuqin.com/webpagedesign/20111220/316487.html

方法一:(js来完成,让底部的ID的值与括号“bottom”一样。)

<script language="JavaScript" type="text/javascript">
function test(){
var infoHeight = document.getElementById("info").scrollHeight;
var bottomHeight = document.getElementById("bottom").scrollHeight;
var allHeight = document.documentElement.clientHeight;

var bottom = document.getElementById("bottom");
if((infoHeight + bottomHeight) < allHeight){
bottom.style.position = "absolute";
bottom.style.bottom = "0";
}else{
bottom.style.position = "";
bottom.style.bottom = "";
}

setTimeout(function(){test();},10);
}
test();
</script>

方法二:(css来完成)

div { style="background:#ededed;height:31px;width:100%;position:fixed;left:auto;right:auto;bottom:0;_position:absolute;_top:expression(document.documentElement.clientHeight + document.documentElement.scrollTop - this.offsetHeight);text-align:center;"}


原创粉丝点击