DOMRect

草案
此页面不完整。

A DOMRect represents a rectangle.

The type of box represented by the DOMRect is specified by the method or property that returned it. For example, VREyeParameters.renderRect from the WebVR API specifies the viewport of a canvas into which visuals for one eye of a head mounted display should be rendered.

It inherits from its parent, DOMRectReadOnly .

构造函数

DOMRect()
创建新的 DOMRect 对象。

特性

DOMRect inherits properties from its parent, DOMRectReadOnly . The difference is that they are not read-only anymore.

DOMRectReadOnly.x
The x coordinate of the DOMRect 's origin.
DOMRectReadOnly.y
The y coordinate of the DOMRect 's origin.
DOMRectReadOnly.width
The width of the DOMRect .
DOMRectReadOnly.height
The height of the DOMRect .
DOMRectReadOnly.top
Returns the top coordinate value of the DOMRect (has the same value as y ,或 y + height if height is negative.)
DOMRectReadOnly.right
Returns the right coordinate value of the DOMRect (has the same value as x + width ,或 x if width is negative.)
DOMRectReadOnly.bottom
Returns the bottom coordinate value of the DOMRect (has the same value as y + height ,或 y if height is negative.)
DOMRectReadOnly.left
Returns the left coordinate value of the DOMRect (has the same value as x ,或 x + width if width is negative.)

方法

DOMRect inherits methods from its parent, DOMRectReadOnly .

静态方法

DOMRectReadOnly.fromRect()
创建新的 DOMRect object with a given location and dimensions.

规范

规范 状态 Comment
Geometry Interfaces Module Level 1
The definition of 'DOMRect' in that specification.
候选推荐 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
DOMRect Chrome Yes Edge 79
79
12
Alternate Name
Alternate Name Uses the non-standard name: ClientRect
Firefox Yes IE No
不支持 No
Yes
Alternate Name
Alternate Name Uses the non-standard name: ClientRect
Opera Yes Safari 10.1 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS 10.3 Samsung Internet Android Yes
DOMRect() 构造函数 Chrome Yes Edge 79 Firefox Yes IE No Opera Yes Safari 10.1 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS 10.3 Samsung Internet Android Yes
Available in workers Chrome 58 Edge 79 Firefox 69 IE No Opera 45 Safari 10.1 WebView Android 58 Chrome Android 58 Firefox Android No Opera Android 43 Safari iOS 10.3 Samsung Internet Android 7.0

图例

完整支持
完整支持
不支持
不支持
使用非标名称。

另请参阅

  1. DOMRect
  2. 构造函数
    1. DOMRect()
  3. 继承:
    1. DOMRectReadOnly
  4. Related pages for Geometry Interfaces
    1. CSSMatrix
    2. DOMMatrix
    3. DOMMatrixReadOnly
    4. Point