From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../web/api/htmlelement/offsetwidth/index.html | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 files/zh-cn/web/api/htmlelement/offsetwidth/index.html (limited to 'files/zh-cn/web/api/htmlelement/offsetwidth') diff --git a/files/zh-cn/web/api/htmlelement/offsetwidth/index.html b/files/zh-cn/web/api/htmlelement/offsetwidth/index.html new file mode 100644 index 0000000000..7fbcfb5266 --- /dev/null +++ b/files/zh-cn/web/api/htmlelement/offsetwidth/index.html @@ -0,0 +1,59 @@ +--- +title: HTMLElement.offsetWidth +slug: Web/API/HTMLElement/offsetWidth +tags: + - API + - 参考 + - 只读属性 + - 属性 +translation_of: Web/API/HTMLElement/offsetWidth +--- +
{{ APIRef("HTML DOM") }}
+ +

HTMLElement.offsetWidth 是一个只读属性,返回一个元素的布局宽度。一个典型的(译者注:各浏览器的offsetWidth可能有所不同)offsetWidth是测量包含元素的边框(border)、水平线上的内边距(padding)、竖直方向滚动条(scrollbar)(如果存在的话)、以及CSS设置的宽度(width)的值。

+ +

语法

+ +
var offsetWidth =element.offsetWidth;
+
+ +

intElemOffsetWidth is a variable storing an integer corresponding to the offsetWidth pixel value of the element. offsetWidth 是一个只读属性。

+ +
+

这个属性将会 round(四舍五入)为一个整数。如果你想要一个fractional(小数)值,请使用{{ domxref("element.getBoundingClientRect()") }}.

+
+ +

示例

+ +

Image:Dimensions-offset.png

+ +

规范

+ + + + + + + + + + + + + + + + +
规范状态备注
{{SpecName('CSSOM View', '#dom-htmlelement-offsetwidth', 'offsetWidth')}}{{Spec2('CSSOM View')}}
+ +

备注

+ +

offsetWidth 是一个 DHTML 对象模型中的属性,由微软 IE 浏览器首次引入。有时候它也可以称为一个元素的物理或图形尺寸,或者 border-box(译者注:即 CSS3中的 border-box 模型)的宽度。

+ +

参见

+ + -- cgit v1.2.3-54-g00ecf