我正在使用一个由多个嵌套div和隐藏输入创建的选择控件。我需要这个包装器div,设置为绝对定位,不占用父级的垂直高度,但如果父级中有滚动,则位于父级div之上。
<style>
.contentOverflow {
width: 450px;
height: 80px;
border: 1px solid red;
overflow: auto;
}
#select_wrapper{
position:relative;
}
#divselect {
margin-top:60px;
background-color:lightblue;
height: 60px;
position: absolute;
top:0px;
overflow:visible;
}
</style>
<div> class="contentOverflow">
<div id="select_wrapper">
<div id="divselect" >
This should display beyond .contentoverflow but must be a child of the .contentoverflow div
</div>
</div>
</div>