DOMRect
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Note: This feature is available inWeb Workers.
ADOMRect describes the size and position of a rectangle.
The type of box represented by theDOMRect is specified by the method or property that returned it. For example,Range.getBoundingClientRect() specifies the rectangle that bounds the content of the range using such objects.
It inherits from its parent,DOMRectReadOnly.
In this article
Constructor
DOMRect()Creates a new
DOMRectobject.
Instance properties
DOMRect inherits properties from its parent,DOMRectReadOnly. The difference is that they are not read-only anymore.
DOMRect.xThe x coordinate of the
DOMRect's origin (typically the top-left corner of the rectangle).DOMRect.yThe y coordinate of the
DOMRect's origin (typically the top-left corner of the rectangle).DOMRect.widthThe width of the
DOMRect.DOMRect.heightThe height of the
DOMRect.DOMRectReadOnly.topReturns the top coordinate value of the
DOMRect(has the same value asy, ory + heightifheightis negative).DOMRectReadOnly.rightReturns the right coordinate value of the
DOMRect(has the same value asx + width, orxifwidthis negative).DOMRectReadOnly.bottomReturns the bottom coordinate value of the
DOMRect(has the same value asy + height, oryifheightis negative).DOMRectReadOnly.leftReturns the left coordinate value of the
DOMRect(has the same value asx, orx + widthifwidthis negative).
Static methods
DOMRect may also inherit static methods from its parent,DOMRectReadOnly.
DOMRect.fromRect()Creates a new
DOMRectobject with a given location and dimensions.
Instance methods
DOMRect may inherit methods from its parent,DOMRectReadOnly.
Specifications
| Specification |
|---|
| Geometry Interfaces Module Level 1> # DOMRect> |