【问题标题】:Footer dynamically动态页脚
【发布时间】:2018-03-01 17:14:38
【问题描述】:

我想动态地将页脚放在底部页面中。

  1. 页脚必须固定在底部

  2. 如果页面中有更多数据,页脚必须自动放置在下方。

html {
    position: relative;
    min-height: 100%;
}

body {
    padding-top: 60px;
    margin-bottom: 75px;
}

footer {
    position: absolute;
    bottom: 0;
    width: 90%;
    height: 45px;
    line-height: 45px;
}
<div id="container"> 
   <div id="main">
    
   </div> 
   
   <div id="footer">
        <div class="container">
            <span>Place sticky footer content here.</span>
        </div>
   </div> 
</div>

【问题讨论】:

标签: html css footer


【解决方案1】:

我可能对您想要什么有点困惑,您希望页脚自动与正文分隔开,而不管添加多少?

试试Position: relative

Absolute 定位将使您的页脚脱离文档流,因此如果您有很多垂直内容,页脚将被放置在其上方。

这对我有用(假设我知道你在追求什么):

footer {
    position: relative;
    bottom: 0;
    width: 90%;
    height: 45px;
    line-height: 45px;
    padding-top: 15px;
}

您可以添加:

margin: 0

如果你想要更小的间距。

【讨论】:

  • 不,我希望我的页脚始终保持向下,如果页面内容很大,我的页脚会自动适应
猜你喜欢
  • 2014-11-27
  • 1970-01-01
  • 2013-06-22
  • 2018-02-05
  • 2018-05-11
  • 2012-08-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多