问题描述
移动H5开发过程中,使用蒙层时,蒙层下方内容会跟随滚动,即滚动穿透。
示例代码如下,手指在屏幕上下滑动时,下方content会跟随滚动,实际上希望此时下方被遮挡,不响应任何操作:
<!DOCTYPE html>
<html>
<head>
<title>滚动穿透</title>
<style type="text/css">
.layer {
position: fixed;
width: 100vw;
height: 100vh;
z-index: 9
}
.content {
height: 110vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="layer"></div>
<div class="content">
top
</div>
</body>
</html>
在移动H5开发中,使用固定位置的蒙层时,下方内容可能会出现滚动穿透现象。本文通过示例代码展示该问题,并提供了解决方案,确保蒙层下方内容在被覆盖时不响应滚动操作。
1293

被折叠的 条评论
为什么被折叠?



