有没有人知道如何将页脚粘贴到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