简体   繁体   English

在没有指定高度的情况下将div放置在另一个div的底部

[英]Positioning a div at bottom of another div without specified height

I Have this HTML 我有这个HTML

<div style="position: relative;">

<div style="top:0">

</div>

<div style='position: absolute; bottom:0; margin-bottom:0px;'>


</div>

</div>

This code is working absolutely fine for IE but on other browsers the two inner div are overlapping, I cannot give any specified height to the outer div. 这段代码对于IE来说绝对正常,但是在其他浏览器上,两个内部div是重叠的,我不能给外部div指定任何高度。

You don't need absolute positioning : 您不需要绝对定位:

<div style="position: relative;">

    <div style="background:black;">
        test
    </div>

    <div style='background:red;'>
        test    
    </div>

</div>

See working fiddle . 参见工作提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM