Search code examples
htmlcssoverflowz-index

z-index + overflow:auto = bug?


I am making popups as position:fixed div and propogate through hierarchy z-index to ensure that this div is on top of everything. Everything fine, except one case when Chrome draw scroll over my popup, iOS safari clips my popop.

I made super small repro https://codepen.io/heavenmaster/pen/XWrQmZY Note, position absolute and setting z-index is essential for me.

I desperately need a workaround.

.scrollview {
  z-index: 1;
  position: absolute;
  margin: 100px;
  width: 200px;
  height: 200px;
  border: solid gray 1px;
  overflow: auto;
}

.container {
  z-index: 1;
  position: absolute;
  width: 1000px;
  height: 1000px;
}

.tooltip {
  z-index: 1;
  width: 250px;
  height: 50px;
  border: solid 1px gray;
  background: silver;
  position: fixed;
  left: 80px;
  top: 80px;
}
<div class='scrollview'>
  <div class='container'>
    <div class='tooltip'>Tooltip</div>
  </div>
</div>


Solution

  • ok let's try this I hope its help:

    .scrollview1
    {
      z-index: 1;
        position: absolute;
        margin: 100px;
        width: 250px;
        height: 200px;
    }
    .scrollview
    {
      z-index: 1;
    /*   position: absolute; */
    /*   margin: 100px; */
      width: 200px;
      height: 200px;
      border: solid gray 1px;
      overflow: auto;
    }
    
    .container{
      z-index: 1;
    /*   position: absolute; */
      width: 1000px;
      height: 1000px;  
    }
    
    .tooltip{
      z-index: 1;
      width: 250px;
      height: 50px;
      border: solid 1px gray;
      background: silver;
      position: fixed;
      left: 80px;
      top: 80px;
    }
    <div class='scrollview1'><div class='scrollview'>   
      <div class='container'>    
        <div class='tooltip'>Tooltip</div>    
      </div>  
      </div></div>