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

Nat*_*man 25 html css alignment

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

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

显然,要做的第一件事就是设定positionfixed.但除此之外......没有任何线索.

Sar*_*raz 34

看看css-tricks:

固定页脚

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');
}
Run Code Online (Sandbox Code Playgroud)


air*_*tyh 21

#mydiv{
   position: fixed;
   bottom: 0px;
}
Run Code Online (Sandbox Code Playgroud)