父 div 高度无效。
wrap 高度不工作。我需要两个子 div absolute。我需要为此使用 css 技巧。不需要 jquery。
任何人都可以帮助我。
<div class="wrap">
<div class="clild"></div>
<div class="clild2"></div>
</div>
<style>
.wrap{
position:relative;
display:block;
width:600px;
margin:0 auto;
}
.clild{
position:absolute;
width:450px;
height:200px;
background:#069;
}
.clild2{
position:absolute;
width:350px;
height:300px;
background:#096;
}
</style>
最佳答案
绝对定位的元素不再是布局的一部分。它们在自己的布局上下文中。因此它们在父元素中不占用空间。
如果想让parent有一个height,就需要赋值一个。
关于jquery - 子div位置绝对父高度不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19666529/