Bilal Halayqa
Bilal Halayqa

Reputation: 972

How to disable scrolling on body when finishing scrolling on a div?

I have a TOC ( Table of content ) on the left of the website as :

#toc
position: fixed;
left: 0;
bottom: 0;
margin: 0;
overflow-y: auto !important;
overflow-x: auto !important;

I can scroll there normally, but when I finish scrolling vertically,the body starts to scroll instead. How do I disable the body from scrolling in this case only..?

Upvotes: 1

Views: 493

Answers (1)

T J
T J

Reputation: 43166

If you want to prevent this behavior, you should add a container element inside your <body> and add the scrolling content inside it and make it scroll instead of <body>. In other words, <body> shouldn't have scroll. If it has scroll browser will pick it up.

Upvotes: 1

Related Questions