2014-09-05 117 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