最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

javascript實(shí)現(xiàn)蒙版與禁止頁(yè)面滾動(dòng)

 更新時(shí)間:2020年01月11日 10:10:57   作者:Original-Heart  
這篇文章主要為大家詳細(xì)介紹了javascript實(shí)現(xiàn)蒙版與禁止頁(yè)面滾動(dòng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了javascript實(shí)現(xiàn)蒙版與禁止頁(yè)面滾動(dòng)的具體代碼,供大家參考,具體內(nèi)容如下

項(xiàng)目需求:頁(yè)面很長(zhǎng),要求加個(gè)蒙版,點(diǎn)擊特定位置蒙版消失可以滑動(dòng)頁(yè)面,否則蒙版存在頁(yè)面不可以滑動(dòng);要同時(shí)兼容移動(dòng)端和pc端。

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name=viewport content="width=device-width,initial-scale=1,user-scalable=no">
  <title>蒙版與禁止?jié)L動(dòng)</title>
  <style>
    .container{
      width:200px;
      height:2000px;
      background-color:blue;
    }
    .modal{
      width: 100%;
      position:fixed;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      z-index: 999;
      background-color: rgba(0,0,0,0.7);
      background-size: 100%; 
    }
    .p{
      font-size: 50px;
      color:red;
      text-align:center;
    }
  </style>
</head>
<body>
  <div class="container">
    <p>內(nèi)容</p>
  </div>
  <!-- 蒙版 -->
  <div class="modal">
    <p class="p">按鈕</p>
  </div>
</body>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>

<script>
$(function(){
  // 阻止蒙版后頁(yè)面滑動(dòng)
  if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
  //移動(dòng)端
    $(".modal").on('touchmove',function(e){
      e.stopPropagation();
      e.preventDefault();
      $('.p').click(function(){
        $(this).parent().hide();    
      })
    })
  } else {
    //PC端
    var flag=true;
    $('.p').click(function(){
      $(this).parent().hide();
      $('body').css({  "overflow":'visible'});
      flag=false;   
    })
    if(flag)
      $('body').css({  "overflow":'hidden' });
  }
})
</script>
</html>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

陆良县| 晋宁县| 东源县| 涪陵区| 友谊县| 台东市| 迁安市| 泸州市| 湖州市| 邵阳市| 乐山市| 平谷区| 建平县| 延寿县| 兖州市| 志丹县| 多伦县| 崇明县| 图们市| 武平县| 丹阳市| 米泉市| 永昌县| 织金县| 乐山市| 绥中县| 绥阳县| 石首市| 通城县| 赣州市| 正蓝旗| 西华县| 巴林左旗| 弥勒县| 镇康县| 兴义市| 汾阳市| 墨玉县| 绵竹市| 兴海县| 隆回县|