开发者社区 问答 正文

移动端Web,如何只能够滑动浮层?

先随便写一个demo

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
    *{margin:0;padding:0;}
        .a{background-color:red;width:100%;height:3000px;}
        .b{position:absolute;top:0;width:100%;height:2000px;background-color:blue;}
</style>
</head>
<body>
    <div class="a"></div>
    <div class="b"></div>
</html>

b是页面弹出的浮层,那么如何控制滑动屏幕的时候只滑动b,而a不滑动?

展开
收起
杨冬芳 2016-06-03 13:59:59 2508 分享 版权
1 条回答
写回答
取消 提交回答
  • IT从业

    终极解决答案... 经过一年多的探索... 给大家一个答案... 我也是日了狗了...
    <body> <ui-view class="container" style="display: block; height: 100%; overflow: auto"></ui-view> <div id="showDetail" class="show-detail" ng-show="showDetail" ng-include="'showDetail.html'"></div> </body>
    这里 ui-view这个标签是正常显示的,点击上面的元素后弹出showDetail。
    一次无意间的测试,在ui-view的标签上加了一个overflow:auto 滚动就不穿透了...
    如果不在对应的需要滚动的容器上,加这个样式的话,最后滚动条会在body上。
    射了这个样式的话 window.on('scroll') 也会失效。这个时候要监听container上scroll

    2019-07-17 19:26:31
    赞同 展开评论