-1

I have found many people asking this question and the answers all involve getting the offset then doing some calculations to include the scroll positions.

But what if the element might be in a parent element that is position:fixed?

Is there a much easier way to calculate the element's position?

hbillings
  • 174
  • 1
  • 1
  • 7

1 Answers1

1

Try element.getBoundingClientRect(); This shouldn't need you to use scroll positions in your calculations.

Hello Dave
  • 231
  • 2
  • 10