Movatterモバイル変換


[0]ホーム

URL:


  1. 面向开发者的 Web 技术
  2. Web API
  3. DOMRect

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in EnglishAlways switch to English

DOMRect

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2020年1月.

一个DOMRect 代表一个矩形。

DOMRect 表示的盒子的类型由返回它的方法或属性指定。例如,WebVR API 的VREyeParameters.renderRect 指定了头戴式显示器的一只眼睛应该呈现的影像所在的canvas 的视口。

它继承自它的父类,DOMRectReadOnly

DOMRectReadOnly DOMRect

构造函数

DOMRect()

创建一个新的DOMRect 对象。

属性

DOMRect 从其父类DOMRectReadOnly 继承属性。不同之处在于它们不再是只读的。

DOMRectReadOnly.x

DOMRect 原点的 x 坐标。

DOMRectReadOnly.y

DOMRect 原点的 y 坐标。

DOMRectReadOnly.width

DOMRect 的宽度。

DOMRectReadOnly.height

DOMRect 的高度。

DOMRectReadOnly.top

返回DOMRect 的顶坐标值(与y 具有相同的值,如果height 为负值,则为y + height 的值)。

DOMRectReadOnly.right

返回DOMRect 的右坐标值(与x + width 具有相同的值,如果width 为负值,则为x 的值)。

DOMRectReadOnly.bottom

返回DOMRect 的底坐标值(与y + height 具有相同的值,如果height 为负值,则为y 的值)。

DOMRectReadOnly.left

返回DOMRect 的左坐标值(与x 具有相同的值,如果width 为负值,则为x + width 的值)。

静态方法

DOMRectReadOnly.fromRect()

创建一个具有指定位置和尺寸的新DOMRect 对象。

规范

Specification
Geometry Interfaces Module Level 1
# DOMRect

浏览器兼容性

更多

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp