儿童div位置绝对父母身高不起作用

Dis*_* TD 3 html css jquery

父div高度不起作用.

包装高度不工作.我需要两个孩子div绝对.我需要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>
Run Code Online (Sandbox Code Playgroud)

Dio*_*ane 12

绝对定位的元素不再是布局的一部分.它们属于自己的布局环境.因此,它们在父元素中不占用空间.

如果您希望父级具有高度,则需要指定一个.