css问题,页面底部的位置div

时间:2011-07-28 11:21:55

标签: html css

我有以下样式来定位div以始终保持在页面底部:

.bottom { background-color:#3B5998;
          height:50px;
          margin-left:0px;
          margin-bottom:0px;
          margin-right:0px }

html, body { margin:0px;
             padding:0px; }

它正在一页但不是第二页!

4 个答案:

答案 0 :(得分:2)

您必须编写如下代码:

.bottom {
    background-color:#3B5998;
    height:50px;
    bottom: 0;
    position:absolute;
    width: 100%;

}

html, body {
    margin:0px;
    padding:0px;
}

参见演示:http://jsfiddle.net/rathoreahsan/YEsq8/

答案 1 :(得分:1)

你也忘记了.bottom:

的一些基础知识
position: absolute;
bottom: 0;

答案 2 :(得分:1)

这是一个很好的工具,可以确保页脚div始终“粘在”页面底部:

http://www.cssstickyfooter.com/

答案 3 :(得分:0)

height:100%min-height:100%添加到您的班级htmlbody

我仍然想知道它在一个页面上是如何工作的,因为我认为你需要某种绝对定位。但请试一试,看看它是否有效。如果没有,请添加您的HTML代码,以便我可以重现您的问题。

相关问题