2014-09-05 111 views
3

我正在尝试修复页脚的错误,因为您可以看到页脚不会停留在浏览器的底部,因此它应该保持在页脚的中间位置该页面如果页面没有足够的内容,它只是遵循div其余部分的高度。网站示例:http://produccion.pugle.net/sarahbcn2/membership-cancelled/不会将页脚固定在底部

因此,我试图修复它与主div包装器上的一些CSS命令,如溢出:自动;或高度:自动;和相同的页脚命令,但没有成功。任何想法如何解决这个问题? 感谢名单

+1

务必将您的代码在这里,而不是链接网站.. – 2014-09-05 08:29:39

+0

Thanx的提示,下次会做! – bonini81 2014-09-05 14:19:50

回答

4

我希望这一决定将帮助您DEMOSticky Footer

<div class="page-wrap"> 

    <h1>Sticky Footer</h1> 
    <h2>with Fixed Footer Height</h2> 

    <button id="add">Add Content</button> 

</div> 

<footer class="site-footer"> 
    I'm the Sticky Footer. 
</footer> 


* { 
    margin: 0; 
} 
html, body { 
    height: 100%; 
} 
.page-wrap { 
    min-height: 100%; 
    /* equal to footer height */ 
    margin-bottom: -142px; 
} 
.page-wrap:after { 
    content: ""; 
    display: block; 
} 
.site-footer, .page-wrap:after { 
    /* .push must be the same height as footer */ 
    height: 142px; 
} 
.site-footer { 
    background: orange; 
} 
+0

Thanx的帮助,但实际上解决了什么事是把脚注在一个固定的位置,位置:固定;/*固定位置*/ – bonini81 2014-09-05 14:24:22

+0

Woops,只是因为这是正确的答案另一个得到的页脚卡在页面上无论如何,即使有内容滚动,页脚总是出现时也会出现很多内容,所以这个问题实际上是人们寻找thanx Alex的原因,因为只有当页脚出现时它不得不固定在底部,而不管它是什么。 – bonini81 2014-09-14 21:14:31

0

将更改应用到您的页脚(使用固定的位置):

footer { 
    background: none repeat scroll 0 center #fff; 
    bottom: 0; 
    display: block; 
    margin: 0 auto; 
    padding: 80px 0 0; 
    position: fixed;/*fixed position*/ 
    width: 100%; 
} 
+0

这解决了这个问题,thanx很多C-LINK !!!!! – bonini81 2014-09-05 14:22:43

+0

不客气! – 2014-09-05 14:23:14