網頁固定底部footer

一、使用flex佈局

<div class="g-container">

<div class="g-real-box"></div>

<div class="g-footer"></div>

</div>

 

.g-container{

height: 100vh;

display: flex;

flex-direction: column;

}

 

.g-footer{

margin-top: auto;

flex-shrink: 0;

height: 30px;

background: yellowgreen;

}

 

二、不使用flex佈局

佈局同上

.g-container {
    width: 100%;
    min-height: 100%;
    margin-bottom: -30px;
}

 

.g-footer {
    height: 30px;
    background: deeppink;
}

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