摘自:http://www.dewen.io/q/1
html結構:
- <div id="container">
- <div id="content">頁面正文</div>
- </div>
- <div class="footer"></div>
CSS樣式:
- html, body{
- height:100%;
- }
- #container {
- min-height:100%; /*使內容高度和body一樣*/
- margin-bottom:-80px;/*向上縮減80像素,不至於footer超出屏幕可視範圍*/
- }
- #content {
- padding-bottom:150px; /*這個是關鍵,處理頁面高度超出屏幕可視範圍時,控制內容和底部高度之間距離*/
- }
- #footer {
- height:80px;
- }