如何将 div 定位到包含 div 的底部?
<style>
.outside {
width: 200px;
height: 200px;
background-color: #EEE; /*to make it visible*/
}
.inside {
position: absolute;
bottom: 2px;
}
</style>
<div class="outside">
<div class="inside">inside</div>
</div>
此代码将文本“inside”放置在页面底部。
.outside {
width: 200px;
height: 200px;
background-color: #EEE; /*to make it visible*/
}
需要是
.outside {
position: relative;
width: 200px;
height: 200px;
background-color: #EEE; /*to make it visible*/
}
绝对定位在 DOM 中查找最近的相对定位父级,如果未定义,它将使用主体。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)