有沒有人知道如何將頁腳粘貼到div的底部,如position: fixed
元素。我發現的所有方法都將其粘貼在起始視圖的底部或底部,因此您必須一直向下滾動才能看到它們。位於div底部的位置元素
我已經試過父position:relative
和孩子設置position: absolute
,並且還使用display: table-cell
和vertical-align: bottom
,但也把它停留在地方當滾動,相反,他們把它靜在在的div或底部默認視圖底部。
.a{
position:relative;
background-color:#ccc;
width:500px;
min-height: 150px;
max-height: 150px;
overflow-y: scroll;
float:left;
padding:8px;
}
.footer{
position:absolute;
bottom:0;
left:0;
width:100%;
background-color:#666;
color:#fff;
}
<div class="a">
Some content<br />Some content<br />Some content<br />Some content<br />Some content<br />Some content<br />Some content<br />Some content<br />Some content<br />Some content<br />Some content<br />Some content<br />Some content<br />Some content<br />Some content<br />Some content<br />Some content<br />Some content<br />Some content<br />
<div class="footer">Some text</div>
</div>
[HTML/CSS定位 「浮動:底部」]的可能的複製(http://stackoverflow.com/questions/526035/html-css-positioning-浮動底部)或http://stackoverflow.com/questions/15358646/css-position-div-to-bottom-of-containing-div – Rob
它不是,答案爲不顯示鎖定項目div的底部 – pfg
它有點。它真的是唯一有效的做法。 – Shaun