日期:2014-05-17  浏览次数:20661 次

CSS如何把DIV永远置于页面的底部?
#footer{
width:100%; 
height:30px;
position:absolute;
bottom:0; 
overflow:hidden;
}
使用该样式在浏览器最大化的时候可以把DIV置于底部,但是窗口进行缩放的时候,该DIV就置于窗口可视范围的底部而不是页面的底部了,形成了漂浮状态。
请问CSS 有什么办法可以让DIV 永远置于页面的底部呢?

------解决方案--------------------
纯CSS不行的话 那就加入JS吧
------解决方案--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>...</title>

<script language="JavaScript" type="text/javascript">

function x(){

var y=""

y+='scrollHeight:'+document.body.scrollHeight;

y+=' offsetHeight:'+document.body.offsetHeight;

y+=' clientHeight:'+document.body.clientHeight;

//document.body.appendChild(document.createTextNode(y))

</script>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><style type="text/css">

<!--

body {

margin-top: 0px;

margin-bottom: 0px;

background:#F00;
}

-->

</style></head>

<body onload="x();">

<table width="514" height="300" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#666666" id="mytab">

<tr>

<td> </td>

</tr>

</table>

</body>

</html>
------解决方案--------------------
#footer{
position: fixed !important;
bottom: 0px;
_position: absolute;
_top: expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight));
}
试试这个。