如何将DIV锚定到页面底部?

时间:2010-06-04 03:51:23

标签: html css alignment

我有一个固定宽度的DIV,我想保留在浏览器视口的底部。

不幸的是,我不知道我甚至会开始尝试实现这一点。

显然,首先要做的是将position设置为fixed。但除此之外......没有任何线索。

2 个答案:

答案 0 :(得分:31)

参见css-tricks:

<强> Fixed Footer

<强> CSS:

#footer {
   position:fixed;
   left:0px;
   bottom:0px;
   height:30px;
   width:100%;
   background:#999;
}

/* IE 6 */
* html #footer {
   position:absolute;
   top:expression((0-(footer.offsetHeight)+(document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight)+(ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop))+'px');
}

答案 1 :(得分:20)

#mydiv{
   position: fixed;
   bottom: 0px;
}
相关问题