I am trying to find the top and left coordinates of a background-image that by applying some CSS rules has been shifted off the viewport. Difficult to explain in words, here is a visual example:
Black box: Viewport
Red box: <div>
with a background-image
Blue box: <div>
containing an <a>
When I do getBoundingClientRect
of the <div>
with the background-image
, I get 0px 0px
. It makes sense, because the container is within the viewport, and it starts at the very top and left.
However, the background-image of that <div>
has been shifted to the left (and it could have been shifted to the top too), and therefore the coordinates should differ from the ones from the <div>
. So my question is:
How would I READ (I don't want to change) How can I find the coordinates of the green point in any page that is facing this situation? I mean, the browser must have known how many pixels it needs to cut the background-image
, right?
I am currently using Javascript to access the Web/Dom API. I am willing to use anything (undocumented maybe?) to achieve this.