滚动固定div时防止正文滚动?

时间:2022-05-26 21:28:18

I've got a fixed slide menu that appears only on mobiles , the problem I got is , when I touch scroll down the menu, all the body elements scrolls down too,I want to prevent body scrolling when touch scrolling the nav element, I tried many js codes but nothing, Help please. PS: The Menu I want to scroll is inside the body, I dont want to prevent it from scrolling too

我有一个固定的幻灯片菜单只出现在手机上,我得到的问题是,当我触摸向下滚动菜单时,所有的身体元素也向下滚动,我想在触摸滚动导航元素时阻止身体滚动,我尝试了很多js代码,但没有,请帮助。 PS:我要滚动的菜单在体内,我不想阻止它滚动

1 个解决方案

#1


0  

First thing would be make the menu big enough that it needs to be scrolled, so, let's say your menu wrapper has a height of 200px. The inner content should have more than 200px, at least.

首先要做的是使菜单足够大以至于需要滚动,所以,假设您的菜单包装器的高度为200px。内部内容至少应该超过200px。

After that you can add overflow-y: scroll; to your menu wrapper CSS selector.

之后你可以添加overflow-y:scroll;到你的菜单包装CSS选择器。

If you face problems, http://iscrolljs.com should help you with that!

如果你遇到问题,http://iscrolljs.com应该帮助你!

#1


0  

First thing would be make the menu big enough that it needs to be scrolled, so, let's say your menu wrapper has a height of 200px. The inner content should have more than 200px, at least.

首先要做的是使菜单足够大以至于需要滚动,所以,假设您的菜单包装器的高度为200px。内部内容至少应该超过200px。

After that you can add overflow-y: scroll; to your menu wrapper CSS selector.

之后你可以添加overflow-y:scroll;到你的菜单包装CSS选择器。

If you face problems, http://iscrolljs.com should help you with that!

如果你遇到问题,http://iscrolljs.com应该帮助你!