在移动设备上,当一个
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设备上尝试过了。如何解决这个问题?