zoukankan      html  css  js  c++  java
  • vue-蒙层弹窗里的内容滚动。外层大页面禁止滚动

     

    此需求 有两种方法,第一种,这种方法适用于,底层 和弹窗是两个平行的没有关系的两部分。重叠(https://blog.csdn.net/yuhk231/article/details/74171734)

    $(".weui-mask").on("touchstart",function(ev){
                var e = ev || window.event;
                e.stopPropagation();
                e.preventDefault();
                alert(e)
         },false);
    

      

     第二种,这种方法比较适用于父子集关系的页面 中(https://blog.csdn.net/zgh0711/article/details/80368710)

     在index.html中

    <script type="text/javascript">
        //解决遮罩层滚动穿透问题,分别在遮罩层弹出后和关闭前调用
        const ModalHelper = ( (bodyCls) =>{
            let scrollTop;
            return {
                afterOpen: function () {
                    scrollTop = document.scrollingElement.scrollTop;
                    document.body.classList.add(bodyCls);
                    document.body.style.top = -scrollTop + 'px';
                },
                beforeClose: function () {
                    document.body.classList.remove(bodyCls);
                    // scrollTop lost after set position:fixed, restore it back.
                    document.scrollingElement.scrollTop = scrollTop;
                }
            };
        })('dialog-open');
    </script>
    

      在全局css中

    body.dialog-open {
        position: fixed;
         100%;
    }
    

      

    对话框弹出后调用

    ModalHelper.afterOpen();

    对话框关闭前调用

    ModalHelper.beforeClose();
  • 相关阅读:
    Java集合类框架的基本接口有哪些?
    JSR303校验 —— hibernate-validator实现
    JSON和对象或集合间的转换
    Servlet 单例、多线程
    session.invalidate()
    request获取各种路径
    动态加载类并实例化对象 —— newInstance
    js 事件冒泡和事件捕获
    js事件绑定
    css 选择器和优先级
  • 原文地址:https://www.cnblogs.com/peko/p/10012166.html
Copyright © 2011-2022 走看看