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;
}

简单,但却是最完美的解决方案。

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