I have a page where a scroll bar containing table rows with divs in them is dynamically generated from the database. Each table row acts like a link, sort of like you’d see on a YouTube playlist next to the video player.
When a user visits the page, the option they are on is supposed to go to the top of the scrolling div. This functionality is working. The issue is that it goes just a tad too far. Like the option they are on is about 10px too high. So, the page is visited, the url is used to identify which option was selected and then scrolls that option to the top of the scrolling div. Note: This is not the scroll bar for the window, it is a div with a scrollbar.
I am using this code to make it move the selected option to the top of the div:
var pathArray = window.location.pathname.split( "https://stackoverflow.com/" );
var el = document.getElementById(pathArray[5]);
el.scrollIntoView(true);
It moves it to the top of the div but about 10 pixels too far up.
Anyone know how to fix that?