getBoundingClientRect()

This Javascript element gives the position of an object in regard to where it is in the window. This means that the object's edges (top, left, bottom, and right) change their values every time the scrolling position changes.

syntax: rectObject = object.getBoundingClientRect()

Visual Presentation

html code

javascript code
css code