讓footer div位於網頁 頁面 底部css3 position:fixed
阿新 • • 發佈:2019-01-31
最簡單的就是:
position:fixed;
bottom:0
其實這是很搓的做法,為什麼?當我頁面比較短的時候,這個div是位於底部的,但是當我頁面比較長的時候,這個div/footer就會覆蓋內容頁,浮在上面了。那怎麼辦?看我的,哇哈哈:
* { margin: 0; } html, body { height: 100%; } .wrapper { min-height: 100%; margin: 0 auto -60px; /* -60pxthe bottom margin is the negative value of the footer's height */ } footer, .push { height: 60px; /* '.push' must be the same height as 'footer' */ }
看到沒有,只要body裡面放一個div class=wrapper,然後後面加一個footer就搞定了, 最主要是-60px這個引數。自己去檢察元素看看就知道了。