DIV相对于父DIV底部对齐的实现方法-Div+CSS教程

时间:2024-02-23 15:15:23

1:

底部对齐的代码(相对于父块):

<style type="text/css">
.box1 {border:1px #cccccc solid; width:500px; height:600px;position:relative;}
.box2 {border-top:1px #cccccc solid; background:#f2f6fb; width:498px; height:22px; position:absolute; bottom:0;}
</style>
<div class="box1">
<div class="box2"></div>
</div>

2:

 

<style type="text/css">
.box1 {border:1px #cccccc solid; width:500px; height:600px;}
.box2 {border-top:1px #cccccc solid; border-bottom:0; background:#f2f6fb; width:500px; height:22px;}
</style>
<div class="box1">
<div class="box2"></div>
</div>