css 响应灵活的高度粘性页脚

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了css 响应灵活的高度粘性页脚相关的知识,希望对你有一定的参考价值。

<!--
The only real caveat to this solution that I’ve encountered so far is the styling limitations present with elements using display: table-row.
Often padding, margin, etc. don’t behave as expected. This is easy enough to work around by adding a <div> or something inside the .page-row and styling that:
-->

<header class="page-row">
  <h1>Site Title</h1>
</header>

<main class="page-row page-row-expanded">
  <p>Page content goes here.</p>
</main>

<footer class="page-row">
  <p>Copyright, blah blah blah.</p>
</footer>
html,
body { height: 100%; }

body {
  display: table;
  width: 100%;
}

.page-row {
  display: table-row;
  height: 1px;
}

.page-row-expanded { height: 100%; }

以上是关于css 响应灵活的高度粘性页脚的主要内容,如果未能解决你的问题,请参考以下文章

在引导程序中具有可变高度的粘性页脚

HTML:使用引导程序添加粘性页脚响应[重复]

CSS中粘性页脚上方的水平和垂直居中

Bootstrap 粘性页脚代码在高度和填充之间发生冲突

如何让粘性页脚工作?

css 页脚粘贴在底部,灵活的高度