2009-10-14 20 views
2

我很難用腳本文本的簡單css代碼段。 頁腳文本必須始終位於頁面末尾屏幕的末尾,不管以後如何。頁腳文本的css

+0

頁面結束*和*屏幕結束?基於此,'頁面末尾'是否不夠?如果頁面在屏幕底部運行,頁腳將位於頁面的底部(即:屏幕上不可見)。如果你滾動到頁面的底部,那麼頁腳仍然在頁面的底部,但在屏幕上可見...也許你想要實現的代碼示例可能會阻止我將自己的思想束縛在邏輯節點上... :) – Town 2009-10-14 11:12:35

+0

如果頁面非常短(只佔用屏幕的一半),那麼我仍然希望頁腳位於屏幕的底部,而不是中間。 – flybywire 2009-10-14 11:27:18

回答

0
* { 
    margin: 0; 
} 
html, body { 
    height: 100%; 
} 
.wrapper { 
    min-height: 100%; 
    height: auto !important; 
    height: 100%; 
    margin: 0 auto -142px; /* the bottom margin is the negative value of the footer's height */ 
} 
.footer, .push { 
    height: 142px; /* .push must be the same height as .footer */ 
} 

/* 

Sticky Footer by Ryan Fait 
http://ryanfait.com/ 

*/ 
-1

使用bottom屬性:

#footer 
{ 
    position:absolute; 
    bottom:2px; 
} 
+0

這會將它放置在視口的底部。如果頁面更長,它不會在頁面底部(具體問題)。 – Quentin 2009-10-14 11:44:03

+0

它會,如果身體標籤的位置:相對; – gnud 2009-10-14 12:01:12

+0

@大衛是的,它會 - 你嘗試過嗎?我用過幾個項目。請參閱http://www.w3schools.com/CSS/pr_pos_bottom.asp – ANaimi 2009-10-14 18:54:47