使用HTML
/CSS
時,即使存在no enough content
,我也需要將footer
放置在頁面的bottom
上。CSS - 即使沒有足夠的內容,也可以將頁腳放在頁面底部
萬一有很多內容導致滾動,很容易實現這一點。當沒有足夠的內容時就會出現問題,因爲在這種情況下,頁腳上升。
在這裏,你有可能澄清圖像這更多:
我有以下起始代碼:
CSS
body {
margin: 0;
}
#header, #content, #footer {
padding: 10px;
}
#header {
height: 100px;
background-color: #abcdef;
}
#content {
bottom: 100px;
left: 0;
right: 0;
background-color: #F63;
overflow: auto;
}
#footer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 100px;
background-color: #abcdef;
}
HTML
<div id="header">
There is the Header
</div>
<div id="content">
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
</div>
<div id="footer">
There is the Footer
</div>
的jsfiddle預覽:https://jsfiddle.net/bk5ow9us/ (嘗試調整窗口的高度)
就如何實現這一目標的任何想法?
重要
我需要的工作溶液也爲IE(版本> = 11),而不僅僅是FF和鉻。
這樣嗎? https://jsfiddle.net/bk5ow9us/1/ –
僅供參考,有大約3000個問題(字面上)已經在網站上提出。我敢打賭,你可以通過一點搜索找到答案。 – TylerH
Ofc這是一個重複的問題,幾乎每天都會問到這個問題。我們應該將他們指向SO文檔,這是他們的全部點 – StefanBob