我如何定位我的div在它的容器底部?给定以下HTML:<div id="container"> <!-- Other elements here --> <div id="copyright"> Copyright Foo web designs </div></div>我想#copyright固守于.的底部#container.我可以在不使用绝对定位的情况下实现这一点吗?如果Float属性支持“底部”的值,那么似乎就可以做到这一点,但不幸的是,它并不支持。
3 回答

森林海
TA贡献2011条经验 获得超2个赞
很可能不会。
指派position:relative到#container,然后position:absolute; bottom:0;到#copyright.
#container {
position: relative;
}
#copyright {
position: absolute;
bottom: 0;
}
<div id="container">
<!-- Other elements here -->
<div id="copyright">
Copyright Foo web designs
</div>
</div>

红糖糍粑
TA贡献1815条经验 获得超6个赞
柔韧箱进场!
.parent { display: flex; flex-direction: column;}.child { margin-top: auto;}
.parent { height: 100px; border: 5px solid #000; display: flex; flex-direction: column;}.child { height: 40px; width: 100%; background: #f00; margin-top: auto;}
<div class="parent"> <div class="child">Align to the bottom</div></div>
.parent { display: flex;}.child { align-self: flex-end;}
.parent { height: 100px; border: 5px solid #000; display: flex;}.child { height: 40px; width: 100%; background: #f00; align-self: flex-end;}
<div class="parent"> <div class="child">Align to the bottom</div></div>
- 3 回答
- 0 关注
- 887 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消