在body外面嵌套一层div,并且动态设置其高度为window.height(),来最终达到在移动端,弹出其它某个页面时,禁止原页面(被div包裹的页面)的滚动。
问题:如何将获取的各屏幕下的高度传给 .wrapper 容器的 height ? 或者其它实现方法?
我要达到的效果,就是overflow:hidden;也就是隐藏滚动条,禁止滚动。
当前使用如下:
overflow:hidden;
position:fixed;
left:0;
top:0;
只是有一个小问题,当触发时,页面会置顶,因为设置了left:0,top:0
我也是用的别人的方法,因为上面的方法有点步问题,所以想试试另一个,但没做出来。
https://www.jb51.net/css/5759...
Html:
<html><style>.wrapper{ height:window.height();//应该是window.height()的高度 }</style><div class="wrapper"><body><p>内容</p></body></div></html>
js类似这样:
var innerHeight = window.innerHeight; var clientHeight = document.body.clientHeight;
相关分类