【问题标题】:How to stick the footer to bottom?如何将页脚粘贴到底部?
【发布时间】:2016-04-12 02:11:53
【问题描述】:

我试图将页脚保持在底部,我是这样做的:

#footer
{
    background-color: #3A3A3A;
    border-top: 1px solid #222222;
    font-size: 11px;
    overflow: auto;
}

#footer #footer-content
{
    padding: 10px 15px;
    display: inline-block;
    float: left;
}

这是html:

<div id="footer">
   <div id="footer-content">
      ...

现在在某些页面中,页脚已正确固定,但在其他页面中,我的控件和页脚之间有很大的空间,因此简而言之,垂直空间很大。如果我调整窗口的大小,页脚会在底部正确地作为另一页返回,而不是保持固定在页脚上。我不明白为什么,我的 css 出了什么问题?

【问题讨论】:

标签: html css


【解决方案1】:

你试过position: fixed吗?

小提琴:https://jsfiddle.net/ar2smzyr/

CSS:

.footer {
  background: red;
  height: 100px;
  position: fixed;
  bottom: 0;
  width: 100%;
}

HTML:

<div class="footer">
  Content
</div>

【讨论】:

  • 或可能是位置:绝对,取决于你的意思
  • @Pamblam 没错,这个问题相当广泛,所以我解释了我个人最喜欢的做法 :-) 不过你是对的 - 胶水是最好的!
  • 无论如何,您的解决方案不起作用我得到相同的结果。我会试试这个:getbootstrap.com/examples/sticky-footer-navbar 无论如何谢谢
  • 没问题 - 它确实有效,因为我已经使用过很多次了,但可能只是不适用于您的项目代码?
  • @Sandokan ..lol 这是确切的解决方案 ..如果你要固执并拒绝解决方案,请不要向人们寻求帮助..
猜你喜欢
  • 2014-11-09
  • 2010-12-02
  • 1970-01-01
  • 2011-10-15
  • 1970-01-01
  • 2020-10-04
  • 1970-01-01
相关资源
最近更新 更多