How to calculate the div position relative to the total browser area? Example: https://i.imgur.com/RPdn8tL.png
I'm referring to the position relative to the entire browser area.
The orange rectangle is at x249 and y346, how i could automatic get this position?
I mean, is possible to read it somewhere or do i need to read something and do a math calc?
CodePudding user response:
You can use javascript for it.
document....offsetLeft
document....offsetTop
Thanks
CodePudding user response:
elem.getBoundingClientRect().x
elem.getBoundingClientRect().y
Where elem is the html object(div, span etc.)