【问题标题】:Footer above bottom of page, instead of being at the bottom of the page content页脚位于页面底部上方,而不是位于页面内容的底部
【发布时间】:2017-01-11 22:00:34
【问题描述】:

我试图让页脚停留在页面底部,而不是屏幕底部(固定),而是在整个页面的底部,因此您只能在滚动到底部后才能看到它。但是,由于某种原因,它停留在底部之上,我似乎找不到原因...... 小提琴: https://jsfiddle.net/okfudezn/

图片:

HTML(div 没有包装等):

<div class="footer">
        <a>REGISTERED NAMES AND TRADEMARKS ARE THE PROPERTY OF THEIR RESPECTIVE OWNERS - Copyright © 2017 All rights reserved</a>
    </div>

CSS:

.footer {
    background-color: #4b4c46;
    height: 55px;
    line-height: 55px;
    width: 100%;
    text-align: center;
    color: #e1dac5;
    font-size: 14px;
}

【问题讨论】:

标签: html css


【解决方案1】:

只需将替换内容的 div 高度更改为自动 updated fiddle

.content {
    position: relative;
    width: 650px;
    height: auto;
    background-color: #e6e6e6;
    border: 1px solid #bcbcbc;
    margin: 0 auto;
    margin-bottom: 80px;
    top: -100px;
}

【讨论】:

  • 但是我现在怎样才能让 div 变小呢?....因为它在底部像地狱一样突出
  • 你在 content css 中使用了top: -100 & margin-bottom: 80px;,删除它
  • 您也可以从网格类中移除高度
【解决方案2】:

我会尝试:

.footer {
    position: absolute;
    bottom: 0;
}

【讨论】:

  • 那是放在屏幕底部,而不是你知道的页面底部吗?
【解决方案3】:

改变这个css

.content {
    background-color: #e6e6e6;
    border: 1px solid #bcbcbc;
    /*height: 650px;*/ /*Remove this*/
    margin: 0 auto 30px;/*Change this*/
    overflow: hidden;/*Add this*/
    position: relative;
    /*top: -100px;*//*Remove this*/
    width: 650px;
}
.grid {
    width: 600px;
    /*height: 1000px;*/ /*Remove this*/
    margin: 0 auto;
    padding-top: 30px;
}

https://jsfiddle.net/okfudezn/

【讨论】:

    【解决方案4】:

    给你!

    html, body {
    	margin:0;
    	padding:0;
      height: 100%;
    }
    
    #container {
      position: relative;
      height: auto;
      min-height: calc(100% - 54px);
      padding-top: 54px; /* Header & Footer */
    }
    
    #header {
      position: fixed;
      top: 0;
      width: 100%;
      height: 54px;
      background: red;
    }
    
    #content {
      background: orange;
      height: 100%;
    }
    
    #footer {
      position: absolut;
      bottom: 0;
      width: 100%;
      height: 54px;
      background: yellow;
    }
    
    .simulateContent {
      height: 1000px;
    }
    <div id="container">
      <div id="header">
        HEADER
      </div>
      <div id="content">
        CONTENT START
        <div class="simulateContent"></div>
        CONTENT END
      </div>
      <div id="footer">
        FOOTER
      </div>
    </div>

    【讨论】:

    • 伙计,我清楚地说我不需要固定的屏幕位置,而是需要将页脚留在页面底部...:|
    猜你喜欢
    • 1970-01-01
    • 2012-01-23
    • 2021-03-20
    • 2012-01-26
    • 2011-11-24
    • 2012-04-24
    • 1970-01-01
    • 1970-01-01
    • 2013-04-02
    相关资源
    最近更新 更多