Prevent parent scroll when in child div

后端 未结 5 1566
野的像风
野的像风 2021-02-08 12:08

When I scroll to the bottom of the child div, the body element starts scrolling.

How can I prevent this? I only want the body to s

5条回答
  •  长发绾君心
    2021-02-08 12:30

    Use this plugin http://mohammadyounes.github.io/jquery-scrollLock/

    It fully addresses the issue of locking mouse wheel scroll inside a given container, preventing it from propagating to parent element.

    It does not change wheel scrolling speed, user experience will not be affected. and you get the same behavior regardless of the OS mouse wheel vertical scrolling speed (On Windows it can be set to one screen or one line up to 100 lines per notch).

    Demo: http://mohammadyounes.github.io/jquery-scrollLock/example/

    Source: https://github.com/MohammadYounes/jquery-scrollLock

提交回复
热议问题