Home > Net >  How can i disable mobile scrolling? Javascript
How can i disable mobile scrolling? Javascript

Time:07-02

I have this website that displays 'The Game of Life', showing a canvas with the cells. On mobile, you can touch the canvas and it draws some cells, but it also scrolls the screen a little bit, even if the content of the web doesn't occupy more than 80% of the screen. I've tried using

body {
     overflow: hidden;
}

But it didn't work Webpage

CodePudding user response:

Try this:

body {
   overscroll-behavior: none; 
   overflow: hidden;
}

CodePudding user response:

I finally solved it. In my CSS i put this:

html, body {
  touch-action: none;
}

Maybe it doesn't work for everyone, but solved my problem. Buttons still work properly :)

  • Related