美文网首页
遮罩鼠标滑轮滚动无效

遮罩鼠标滑轮滚动无效

作者: 诸葛振坤 | 来源:发表于2017-09-12 19:30 被阅读0次
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>遮罩层禁止底层滚动条滚动</title>
  <style>
      *{
        margin: 0;
        padding: 0;
      }
      ul,li{
        list-style:none;
      }
      li{
        width: 800px;
        height: 500px;
        background:red;
        margin-top:10px;
      }
      #btn{
        position: fixed;
        top:500px;
        right:200px;
      }
      #shade{
        position: fixed;
        top:0;
        bottom:0;
        left:0;
        right:0;
        background:rgba(0, 0, 0, .5);
        display: none;
      }
  </style>
</head>
<body>
  <ul>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
  </ul>
  <button id="btn">遮罩层</button>
  <div id="shade"></div>

  <script>
      var btn=document.getElementById("btn");
      var shade=document.getElementById("shade");
      btn.onclick = function(){
        shade.style.display = "block"; 
        window.onmousewheel=function(){return false};   
      }
  </script>
</body>
</html>

相关文章

网友评论

      本文标题:遮罩鼠标滑轮滚动无效

      本文链接:https://www.haomeiwen.com/subject/tlhhsxtx.html