2012-04-05 142 views
0

我想將3個子div對齊到父母的底部,我嘗試使用margin-top但它移動了洞的東西。如何將div對齊到另一個div的底部

<div style="border:1px solid red;width:200px;height:100px;"> 


<div style="height:72px;width:96px;margin:9px;"> 

<div style="background-color:red;height:47px;text-align:center;">This div</div> 

</div> 


</div> 

回答

0

您可以將第三個div添加到#child div中。

<div id="parent"> 
    <div id="child"> 
     content 
    </div> 
</div> 

#parent { 
    position: relative; 
    width: 200px; 
    border: 1px solid red; 
    height: 100px; 
} 
#child { 
    position: absolute; 
    bottom: 0; 
    left: 0; 
    width: 100%; 
    height: 50px; 
    background-color: red; 
} 
0

風格的父DIVposition: relative;和使用position: absolute; bottom: 0;孩子DIV

+0

小孩div消失.. – Ben 2012-04-05 05:53:21