如何固定一个DIV到页面的底部?页面、DIV

2023-09-11 07:44:02 作者:不疯不傻的丶小世界﹌

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

I have a fixed-width DIV that I want to remain at the bottom of the browser's viewport.

不幸的是,我还没有线索,我甚至会开始尝试实现这一点。

Unfortunately, I haven't a clue where I would even begin to try to implement this.

显然,要做的第一件事是将位置固定。但除此之外......不知道。

Obviously the first thing to do is set position to fixed. But beyond that... no clue.

推荐答案

请参阅在CSS-招数:

See at 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');
}