Sys.UI.Bounds 类

更新:2007 年 11 月

创建一个对象,该对象包含一组表示位置、宽度和高度的整数坐标。

命名空间:Sys.UI

**继承:**无

var objectBoundsVar = new Sys.UI.Bounds(x, y, width, height);

构造函数

名称

说明

Sys.UI.Bounds 构造函数

初始化 Sys.UI.Bounds 类的新实例。

成员

名称

说明

Sys.UI.Bounds height 属性

获取 Bounds 对象的高度(以像素为单位)。

Sys.UI.Bounds width 属性

获取 Bounds 对象的宽度(以像素为单位)。

Sys.UI.Bounds x 属性

获取 Bounds 对象的 x 坐标(以像素为单位)。

Sys.UI.Bounds y 属性

获取 Bounds 对象的 y 坐标(以像素为单位)。

备注

Sys.UI.DomElement 类的 getBounds 方法返回一个 Bounds 对象。

示例

下面的示例演示如何使用 Bounds 类。

// Get the bounds of the element
var elementRef = $get("Label1");
var elementBounds = Sys.UI.DomElement.getBounds(elementRef);
var result = '';
result += "Label1 bounds x = " + elementBounds.x + "<br/>";
result += "Label1 bounds y = " + elementBounds.y + "<br/>";
result += "Label1 bounds width = " + elementBounds.width + "<br/>";
result += "Label1 bounds height = " + elementBounds.height + "<p/>";
// Get the bounds of the element
var elementRef = $get("Label1");
var elementBounds = Sys.UI.DomElement.getBounds(elementRef);
var result = '';
result += "Label1 bounds x = " + elementBounds.x + "<br/>";
result += "Label1 bounds y = " + elementBounds.y + "<br/>";
result += "Label1 bounds width = " + elementBounds.width + "<br/>";
result += "Label1 bounds height = " + elementBounds.height + "<p/>";

请参见

参考

new 运算符

其他资源

语言参考