Sticky footer is not placed at the bottom

情到浓时终转凉″ 提交于 2019-12-11 14:07:02

问题


I'm just making some quick changes to the footer.

The footer needs to be sticky, i was following the method described by A List Apart method to try get the footer to stay at the bottom, but it seems to be off just a little bit.

html, body {
height: 100%;
 }
#container {
position: relative;
min-height: 100%;
}

<div id="container">
    <div id="content">...</div>
    <div id="footer">...</div>
</div>

回答1:


I always use the CSSStickyFooter method.

  • HTML, a basic skeleton

    <div id="wrap">
    
        <div id="main">
    
        </div>
    
    </div>
    
    <div id="footer">
    
    </div>          
    
  • CSS, this is only a snippet

    * {margin:0;padding:0;} 
    
    html, body {height: 100%;}
    
    #wrap {min-height: 100%;}
    
    #main {overflow:auto;
        padding-bottom: 180px;}  /* must be same height as the footer */
    
    #footer {position: relative;
        margin-top: -180px; /* negative value of footer height */
        height: 180px;
        clear:both;} 
    



回答2:


I think you should add to #wrapper clearfix, add height: 100% to #wrapper and #container in this case, you will see footer lower then should be. Now you should set top to minus height of footer and it should work. Bo I don't know if it will cover content of wrapper.



来源:https://stackoverflow.com/questions/14877482/sticky-footer-is-not-placed-at-the-bottom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!