2

I have a modal that pops up on my website when a user clicks a button. However, when the modal is open, the user can still scroll the page behind it, which is causing issues with the layout and user experience. I want to prevent scrolling when the modal is open, but allow scrolling when the modal is closed.

I've tried adding overflow: hidden to the body element, but this prevents scrolling even when the modal is closed. Is there a way to disable scrolling only when the modal is open, and re-enable scrolling when the modal is closed? Any help or suggestions would be appreciated.

yus.rar
  • 31
  • 1
  • 1
    Since you are using javascript just add a class to the body that sets overflow to hidden when the modal opens and when the modal is closed, remove that class. – imvain2 Apr 21 '23 at 20:23

0 Answers0