如何在页面底部放置div

时间:2011-04-05 06:39:47

标签: jquery html css position

如何使用CSS或jQuery将<div>的位置设置到页面底部?

6 个答案:

答案 0 :(得分:11)

使用position:absolutebottom:0

检查工作示例。 http://jsfiddle.net/gyExR/

答案 1 :(得分:6)

如果您愿意,可以使用position:absolute;bottom:0;

答案 2 :(得分:2)

in css: position:absolute position:fixed

答案 3 :(得分:1)

这已经得到了解答,但为非CSS专家提供了更多的背景信息:

给出HTML

<html>
  <body>
    <p>Some content</p>
    <div class="footer">down there</div>
  </body>
</html>

然后是以下css

div.footer {
  position: absolute;
  bottom: 0;
  right: 0;
}

将文本放在视口(浏览器窗口)的右下角。滚动将移动页脚文本。

如果您使用

div.footer {
  position: fixed;
  bottom: 0;
  right: 0;
}

另一方面,即使滚动,页脚仍将保留在视口的底部。同样的技术可以与top: 0left: 0 btw一起使用,以将元素定位在左上角。

答案 4 :(得分:1)

position:fixed;bottom:0;的组合适用于我。

答案 5 :(得分:0)

我认为你可以这样做:

    html{
      min-height:100%;
      position:relative;
      background-color:red;
    }
    .footer{
      bottom:0;
      position:absolute;
      background-color:blue;
    }
<html>
  <body>
    <div class='footer'>
    <h1>I am Footer</h1>
    </div>
    </body>
  </html>

相关问题