0

I have a modal where the content of the modal is longer than the modal height so there is a scrollbar

The content of the modal is a survey. If the survey is not taken then the modal opens at the top of the survey

But if the survey has been taken and a person comes back to change their answers the modal opens at the bottom of the survey and people often do not realize they are at the bottom of the survey, not the top

How to open the modal so it opens at the top of the modal content regardless of whether the survey has been taken or not

Is there a way to do this with CSS?

Thank you

enter image description here

xyz
  • 2,253
  • 10
  • 46
  • 68
  • 1
    With only CSS, might not be, since its browser behavior. Check this answer https://stackoverflow.com/questions/48308390/javascript-prevent-browser-from-restoring-scroll-positions-when-using-the-back – Anurag Srivastava Apr 06 '21 at 18:02
  • Anurag Thank you – xyz Apr 06 '21 at 18:04

1 Answers1

1

I think you can't solve it with css.

But which language do you use? If you use something like React, that means your programming language is JavaScript, you can use this:

window.scroll(0, 0); If you set it up at the top of your modal, every time you open it, it starts at the top.

If you use something other language, I think you find a similar code-example.

lomu98
  • 55
  • 7