简体   繁体   中英

Scrollable element blocked by overlay div

I have a requirement to have an overlay div positioned (z-order) above a [pre] element that is scrollable. The problem is, I can no longer scroll within the pre element because the overlay is blocking it.

Q: Is there any way to pass scroll events through divs so that they reach underlying elements?

CSS:

.dropzone {

    pointer-events:none;
}

#myimage {

    float: left;
    border-width: 0px; 
    border-style: none; 
    background-color:none;
    padding: 0px;
    position: relative;
}


#myoverlay {

    position: absolute;
    background-color:#139C8A;
    background-image: url('../images/drag-icon-white.png');
    background-size: 160px 66px;
    background-repeat: no-repeat;
    background-position: center;
    opacity:0.0;
    z-index:-1;
}

#myresponse {

    float: right;
    border-width: 0px; 
    border-style: none; 
    background-color:none;
    padding: 0px;
    position: relative;
}

 .mycode {

    text-align:left;
    color:#EFEFEF;
    background-color:#3C3C48;
    border-width: 0px; 
    border-style: none;
    overflow-y: scroll; 
    position: relative;

}

HTML:

<div class="container">
  <div id="myoverlay">&nbsp;</div>
  <div class="row">
        <div class="col-md-12">
          <div id="myimage">
            <canvas id="myCanvas" width="970" height="485"></canvas>
          </div> <!-- end col-md-4 -->
          <div id="myresponse">
            <pre id="mycode" class="mycode">
              <span style="color:#139C8A"><i>(Response will appear here)</i></span>
            </pre>
          </div>
          <div id="dropzone" class="dropzone-detect detect-droppable"></div>
        </div>
  </div><!-- end row -->
</div> <!-- /container -->

You've assigned the CSS to the class .dropzone . But there is no dropzone-class, just an ID! Try the following CSS:

#dropzone { pointer-events:none; }

But please note, that this isn't working in IE below version 11 . For those browser, you can use a polyfill .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM