您的位置:首页 > 其它

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

2012-07-31 13:09 501 查看
参考文档: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;"}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: