2013-03-24 50 views
1

我知道有很多關於粘性頁腳的問題,但我似乎無法讓他們在我的頁面上工作。如何獲得粘腳?

任何人都可以幫助我讓我的頁腳粘性,不固定?

我的HTML

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

我的CSS

#container { 
    width: 980px; 
    min-height: 100%; 
    margin-left: auto; 
    margin-right: auto; } 

#content { 
    width: 100%; 
    min-height: 100%; 
    margin: 40px 0; } 

#footer { 
    width: 3000px; 
    min-height: 185px; 
    background-color: rgb(0,173,239); 
    margin-left: -1000px; } 

我曾嘗試過各種職位(相對固定等),但它不工作。我似乎修復了我的頁腳並覆蓋了內容。有什麼建議麼?

+1

你看看[cssstickyfooter.com(http://www.cssstickyfooter.com/)?另外:告訴我們你想要/需要支持哪些瀏覽器。 – Jeroen 2013-03-24 20:31:55

+0

是的,我有,我不能得到它的工作。我想在所有瀏覽器(鉻,FF,Safari,IE 8和9)上支持。 – 2013-03-24 20:59:04

回答

0

試試這個CSS:

body { 
    min-height: 100%; } 

#container { 
    width: 980px; 
    min-height: 100%; 
    margin-left: auto; 
    margin-right: auto; } 

#content { 
    width: 100%; 
    min-height: 100%; 
    margin: 40px 0; 
    margin-bottom: 290px; } 

#footer { 
    width: 100%; 
    min-height: 185px; 
    background-color: rgb(0,173,239); 
    position: fixed; 
    bottom: 0; 
    left: 0; 
    right: 0; } 
+0

這涵蓋了較長頁面上的內容,這就是爲什麼我想要一個粘性頁腳而不是固定的 – 2013-03-24 20:50:48

+0

您可以發送截圖嗎?你使用什麼瀏覽器? – aNewStart847 2013-03-24 20:52:51

+0

我想要所有的瀏覽器。我想讓頁腳坐在內容的底部,但是如果頁面很短,那麼就讓頁腳坐在頁面的底部 – 2013-03-24 20:58:20