Home > Net >  Disable manual scroll in CSS
Disable manual scroll in CSS

Time:12-15

I'm using CSS smooth scroll - which is triggered by clicking a div.

Now I want to disable manual scrolling, so you can only scroll by clicking that div and not by actually scrolling.

Is it possible? Thx.

CodePudding user response:

CSS overflow property can help the situation. Give,

overflow-y:hidden;

This will resist the scroll event over the section you are providing overflow hidden.

Please provide the overflow:hidden to the required section alone, so that it will not affect the other part of the page.

CodePudding user response:

Using this little snippet below, you won't be able to scroll and the scroll bar wont be visible.

body {
  overflow-y: hidden;
}

using ::-webkit-scrollbar isn't a possibility because you will still be able to scroll.

  • Related