I have an absolutely positioned div that acts like a modal window in the center of the page. The modal window scrolls vertically using the scroll bar on the right side. The page itself also scrolls vertically using the scroll bar on the right. I would like to be able to click on the link and scroll the modal window to the related item.
I can pretty much achieve this using target.scrollIntoView (); but the whole page scrolls along with the modal window - I would like the page to not move and only have to scroll the modal window. If I use scrollIntoView (false), the page itself does not scroll, while the modal window does, but the target element is at the bottom of the window, while I would like it to be at the top.
Is there a way that I can manually shift the position of a target in a div? that is, if I use scrollIntoView (false), the target is displayed at the bottom of the div - if I could then shift it to the height of the viewport, could I move it to the beginning.?
Note. I can not use jQuery and the like. for this.
Thanks in advance for your help.
source
share