-2

I know that the css rule overflow-x:hidden on the body and html elements can be used to prevent horizontal scrolling. But what to do if you want to use the jquery scrollTop(), that does not work if you have that particular css rule enabled?

I would really like to have both things working. Anyone with another idea for preventing horizontal scrolling?

TBJ
  • 407
  • 4
  • 19

1 Answers1

2

In case anyone else is searching for an answer I found it here. The solution is to create a site wrapper div inside the body and applying the overflow-x:hidden to the wrapper instead of the body or html the issue is fixed.

TBJ
  • 407
  • 4
  • 19
  • They are styled correctly and does not cause horizontal overflow on desktop screens. For some reason this css rule is necessary to prevent endless horisontal scrolling in some mobile devices. This seems to be a common solution, as far as I can tell after reading up on the subject. – TBJ Jan 17 '18 at 09:54