【问题标题】:How do I get a sticky footer?如何获得粘性页脚?
【发布时间】:2013-03-25 05:08:38
【问题描述】:

我知道有很多关于粘性页脚的问题,但我似乎无法让它们在我的页面上工作。

谁能帮我让我的页脚变粘,而不是固定?

我的 HTML

<div id="container">
      <div id="header"></div>
      <div id="content"></div>
      <div id="footer"></div>
</div>

我的 CSS

#container {
    width: 980px;
    min-height: 100%;
    margin-left: auto;
    margin-right: auto; }

#content {
    width: 100%;
    min-height: 100%;
    margin: 40px 0;  }

#footer {
    width: 3000px;
    min-height: 185px;
    background-color: rgb(0,173,239);
    margin-left: -1000px;  }

我尝试了各种职位(相对、固定等),但都不起作用。我似乎修复了页脚并覆盖了内容。有什么建议吗?

【问题讨论】:

  • 你看过cssstickyfooter.com吗?另外:告诉我们您想要/需要支持哪些浏览器。
  • 是的,我有,但我无法让它工作。我想要所有浏览器(chrome、FF、safari、IE 8 和 9)的支持

标签: html css sticky-footer


【解决方案1】:

试试这个 CSS:

body {
    min-height: 100%; }

#container {
    width: 980px;
    min-height: 100%;
    margin-left: auto;
    margin-right: auto; }

#content {
    width: 100%;
    min-height: 100%;
    margin: 40px 0;
    margin-bottom: 290px;  }

#footer {
    width: 100%;
    min-height: 185px;
    background-color: rgb(0,173,239);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;  }

【讨论】:

  • 这涵盖了较长页面上的内容,这就是为什么我想要一个粘性页脚而不是固定页脚
  • 可以发截图吗?你用什么浏览器?
  • 我想要所有浏览器。我希望页脚位于内容的底部,但如果页面很短,则让页脚位于页面底部
  • 好的,我有两个想法:添加 min-height:100%;身体或尝试cssstickyfooter.com,因为它应该可以工作......
  • 我在 body 和 html 中添加了 min-height 100%。答对了!谢谢
猜你喜欢
  • 2017-08-24
  • 2012-09-03
  • 2013-02-23
  • 2013-03-18
  • 2012-08-04
  • 1970-01-01
  • 2023-01-16
  • 2014-09-28
  • 2017-06-26
相关资源
最近更新 更多