1. 程式人生 > >CSS Sticky footer完美底部佈局

CSS Sticky footer完美底部佈局

html結構:

<div class="container">
    <div class="content-wrapper>
       <div class="content">內容區域,可隨機長度</div>
    </div>
    <div class="close">
<div>
<div class ="close">關閉圖示</div>始終再底部.

css程式碼:

.container{//總容器為全屏,所以高度為100%
  positon: fiexd;
  top
:0; left:0; height:100%; overflow: auto;//如果內容太長,會顯示滾動條檢視其餘內容。 } .content-wrapper{ min-height: 100%;//如果內容不夠長時,也保證內容有全屏長度 } .content{ margin-top: 50px;//向上和螢幕頂部保持50px間距 padding-bottom: 50px;//保證內容content區域的底部有50px的空白 } .close{ margin: -64px;//讓關閉按鈕向content-wrapper裡面伸入50px,正好把內容區的50px空白補上; }

最終效果:

這裡寫圖片描述