HTML DIV层内对齐

徘徊边缘 提交于 2019-11-27 06:15:44

2.DIV层内对齐

DIV怎么相对父DIV底部对齐

比如这样:


<style type="text/css">
.box1 {border:1px #cccccc solid;   width:500px; height:600px;}
.box2 {border-top:1px #cccccc solid; border-bottom:1px #cccccc solid; background:#f2f6fb; width:500px; height:22px;}
</style>
<div class="box1">
     <div class="box2">我要怎么才可以对齐底部</div>
</div>


实现对齐底部:


<style type="text/css">
.box1 {border:1px #cccccc solid;   width:500px; height:600px;position:relative;}
.box2 {border-top:1px #cccccc solid; border-bottom:1px #cccccc solid; background:#f2f6fb; width:498px; height:22px; position:absolute; bottom:10;}
</style>
<div class="box1">
     <div class="box2">我对齐底部了</div>
</div>
position:relative; 想让嵌套层以父层为参考定位,主要是这个属性,父div相对定位,然后子div再用绝对定位就可以了
position:absolute; bottom:10;相对于父对像.10象素.

转载于:https://www.cnblogs.com/hakuci/archive/2010/12/20/1911169.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!