getBoundingClientRect
The getBoundingClientRect() method returns a DOMRect object that contains properties describing the position and size of an element relative to the viewport.
The properties of the DOMRect object are:
x: the horizontal coordinate of the top-left corner of the rectangle relative to the viewport.y: the vertical coordinate of the top-left corner of the rectangle relative to the viewport.width: the width of the rectangle.height: the height of the rectangle.top: the distance from the top edge of the viewport to the top edge of the rectangle.right: the distance from the left edge of the viewport to the right edge of the rectangle.bottom: the distance from the top edge of the viewport to the bottom edge of the rectangle.left: the distance from the left edge of the viewport to the left edge of the rectangle.
This method is often used to get the position and size of an element so that it can be positioned or manipulated dynamically with JavaScript.
原文地址: https://www.cveoy.top/t/topic/IJA 著作权归作者所有。请勿转载和采集!