将div对齐到底部

时间:2012-09-06 11:15:56

标签: css html vertical-alignment

我必须将div添加到另一个div中,位置绝对(不能相对)到底部,代码看起来像

<div style="position:aboslute; top:100px; left:200px; height:500px">
    <div style="height:20px">Example 1</div>
    <div style="height:2px">Example 2</div>
</div>

解决方案?

1 个答案:

答案 0 :(得分:1)

relative位置提供给父级,将absolute位置提供给子级。

<div style="position:aboslute; top:100px; left:200px; height:500px">
    <div style="height:20px; position: absolute; bottom: 0;">Example 1</div>
    <div style="height:2px; position: absolute; bottom: 0;">Example 2</div>
</div>

预览:

Align divs to the bottom

在这里查看小提琴:http://jsfiddle.net/vLn32/

相关问题