如何让DIV层永远置于网页窗口的最底部Bottom

本文介绍了一种使用CSS实现底部元素固定显示的方法,并针对不同浏览器提供了兼容性解决方案。通过绝对定位和条件注释,确保了在IE和其他浏览器中底部提示信息能够正确展示。

<style type="text/css">
html,body{height:100%;margin:0;padding:0;}
#bottomDiv{ /*Code for Moz, Opera, etc.*/
height:50px;
width:100%;
background:#9bb;
position:fixed;
bottom:0;
}
#scaleDiv{
position:absolute;
visibility:hidden;
height:100%;
}
</style>
<!--[if IE]>
<style type="text/css"> /*IE-specific markup*/
#bottomDiv{
position:absolute;
top:expression(offsetParent.scrollTop + (document.getElementById("scaleDiv").offsetHeight-50));
}
</style>
<![endif]-->


<div id="scaleDiv">
<!-- this div is to find browser page display height -->
</div>
<div style="font:4em Verdana;padding-bottom:2em;"><!-- bottom padding allows content to clear on scroll -->
hello hello
hello hello
hello hello
hello hello
hello hello
hello hello
hello hello
hello hello
hello hello
hello hello
hello hello
hello hello
hello hello
hello hello
hello hello
hello hello
hello hello
hello hello
hello hello
hello hello

 

</div>
<div id="bottomDiv">
<p style="text-align: center; color: white">I am here</p>
</div>
 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值