【发布时间】:2015-08-24 22:11:57
【问题描述】:
在移动设备上,当屏幕上出现position:fixed; 元素时,用户可以滚动<body>,通过固定元素。
body,
html{
overflow: hidden;
margin: 0;
padding: 0;
}
#fixed {
background: red;
position: fixed;
left:0;
top: 0;
width: 200px;
height: 100%;
}
#content {
background: blue;
height: 3000px;
}
我尝试为<html> 和<body> 添加overflow:hidden,但没有帮助。我想阻止滚动固定元素,但我想允许滚动,当固定元素可见但用户滚动<body>。
我在 ios 和 android 设备上试过这个。解决这个问题的最佳解决方案是什么?
【问题讨论】:
-
对此有任何答案吗?只有 CSS 的解决方案会很棒。