當(dāng)頁面高度小于文檔內(nèi)部高度時,頁腳也處于最底部的實現(xiàn)方式
- CSS
html,body{
width: 100%;
margin: 0;
padding: 0;
}
html{
min-height: 100%; /* 這個要設(shè)置最小高度 */
position: relative;
}
body{
margin-bottom: 60px; /* footer的高度 */
}
.footer{
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 60px;
background-color: #ff0000;
}
- html
<body>
<div class="footer"></div>
</body>