子div扩展超出父溢出的div

时间:2018-02-12 17:56:42

标签: html css user-interface position

我正在使用一个由多个嵌套div和隐藏输入创建的选择控件。我需要这个包装器div,设置为绝对定位,不占用父级的垂直高度,但如果父级中有滚动,则位于父级div之上。

Codepen

<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>

0 个答案:

没有答案