Sticky Footer - 讓footer永遠置於頁面最底端

我們常常需要把footer放置在頁面的最低端,那麼如果頁面的內容高度不夠,footer並不會自動置於底端。我們需要進行自定義CSS:

html {
    min-height: 100%; /* 非常重要 */
    position: relative;
}

body {
    /* Margin bottom by footer height */
    margin-bottom: 80px;
}

.footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 80px;
}

簡單,但卻是最完美的解決方案。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章