js see how for from top an element is relative to page code example
Example: javascript get element position relative to document
element.getBoundingClientRect().top + document.documentElement.scrollTop
element.getBoundingClientRect().top + document.documentElement.scrollTop