【问题标题】:How to have a footer in the bottom of the page on any case?在任何情况下如何在页面底部添加页脚?
【发布时间】:2020-09-05 16:34:35
【问题描述】:

我想在 HTML 页面的底部有一个固定的页脚,即使是 XS 和 SM 尺寸。

当我把它设为相对时,它取决于显示的内容,我希望它固定在底部。

有人可以帮我吗?

【问题讨论】:

标签: html css twitter-bootstrap footer


【解决方案1】:

您可以使用以下样式:

position: fixed;
bottom: 0;
left: 0;
right: 0;

您当然必须根据您的具体情况对其进行调整。如果您有代码示例,我可以为您提供更具体的内容。

【讨论】:

  • 是的,实际上当我传递给 XS 一个 SM 时,页脚在底部,但在正文的底部。所以我的页脚位于页面的中间......
  • @jozinho22 我没有看到这个,但这可能是与htmlbody 高度定义相关的问题。虽然这些并没有真正影响position: fixed
【解决方案2】:

这就是你获得粘性页脚的方式

body{
min-height: 100vh;
flex-direction: column;  
}

footer{
  margin-top:auto;
}

【讨论】:

    猜你喜欢
    • 2015-05-11
    • 2013-11-18
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 2021-06-24
    • 2021-02-07
    • 2013-07-06
    • 2023-04-01
    相关资源
    最近更新 更多