【问题标题】:Footer is not fixed at the bottom页脚未固定在底部
【发布时间】:2021-03-09 15:00:06
【问题描述】:

当页面内容小于窗口高度时,页脚不固定在底部。下面是截图..

内容超过窗口大小:

内容小于窗口高度:

HTML:

<footer class="page-footer text-center font-small mt-4 wow fadeIn">


        <div class="pt-4">
          <a class="btn btn-outline-white" href="https://mdbootstrap.com/docs/jquery/getting-started/download/" target="_blank"
            role="button">Download MDB
            <i class="fas fa-download ml-2"></i>
          </a>
          <a class="btn btn-outline-white" href="https://mdbootstrap.com/education/bootstrap/" target="_blank" role="button">Start
            free tutorial
            <i class="fas fa-shopping-cart ml-2"></i>
          </a>
        </div>
        <!--/.Call to action-->

        <hr class="my-4">

        <div class="footer-copyright py-3">
          © 2019 Copyright:
          <a href="https://mdbootstrap.com/education/bootstrap/" target="_blank"> MDBootstrap.com </a>
        </div>
        <!--/.Copyright-->

      </footer>

CSS:

.main-container {
 min-height: 100vh; /* will cover the 100% of viewport */
 overflow: hidden;
 display: block;
 position: relative;
 padding-bottom: 100px; /* height of your footer */
}
footer {
 position: absolute;
 bottom: 0;
 width: 100%;
}

【问题讨论】:

  • 你能链接一些代码吗?
  • @AndersSørensen 不,在 SO,我们不想要 “链接代码” ...请阅读 minimal reproducible example,上面写着一个可验证的样本 within 问题本身
  • 我正在使用 django 和 bootstrap 构建一个网站。我对 HTML 和 CSS 的了解有限。当我进行一些更改时,我将发布影响视图的 CSS。
  • @LGSon, …Minimal – 使用尽可能少的代码,但仍会产生相同的问题 …Complete – 提供其他人需要在问题本身中重现您的问题的所有部分 …Reproducible – 测试您的代码'即将提供以确保它重现问题。 Anders 询问了您发送的示例中提到的 1 和 2 点的代码。那么你说不的必要性是什么?

标签: html css twitter-bootstrap


【解决方案1】:

强文本

只需在页脚类中添加固定底部

footer class="page-footer text-center font-small mt-4 wow fadeIn fixed-bottom"

希望这能解决你的问题

【讨论】:

    【解决方案2】:

    这解决了我的问题。现在无论内容和窗口大小如何,页脚都固定在底部。

    <footer style="position: fixed; bottom: 0; width: 100%;" class="page-footer text-center font-small mt-4 wow fadeIn  ">
    

    【讨论】:

      猜你喜欢
      • 2015-05-15
      • 1970-01-01
      • 2017-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-25
      • 2016-12-01
      相关资源
      最近更新 更多