Dear forum members, really need your help! I’m about to hand in a project, and I’ve been trying to solve one problem for half a day.
I have a modal window.
For the mobile version I had to add to the modal window - scroll.
-! But the problem is that on the published site, in the mobile version, when I open the modal window, the scroll is pressed down, showing the end of the content. And I need the scroll to be at the top. At the beginning of the modal window content.
Maybe you have a tutorial how to make this scroll in the modal window.
Please tell me how to solve this problem(((
I will be very grateful !
Photo from developer mode: scroll is there, but pressed to the bottom
Hello Pavel
i tried to find the reason of this problem with inspect
i realized that when i remove the button in your modal
scroll problem does not happen
and in your modal button i think if you change tabindex = “0” to tabindex = “-1”
your problem will be fixed
CSS: Ensures the modal is styled correctly and is scrollable.
JavaScript:
modalContent.scrollTop = 0; ensures the scroll position is at the top when the modal is opened.
Functions to open and close the modal.