HTMLElement.offsetWidth 是一个只读属性,返回一个元素的布局宽度。一个典型的(译者注:各浏览器的offsetWidth可能有所不同)offsetWidth是测量元素的边框(borders)、水平线上的内边距(padding)、竖直方向滚动条(scroolbar)(如果存在的话)、以及CSS设置的宽度(width)的值。
语法
var offsetWidth =element.offsetWidth;
offsetWidth
是一个只读属性。
示例
padding-top
Gentle, individualistic and very loyal, Birman cats fall between Siamese and Persian in character. If you admire cats that are non aggressive, that enjoy being with humans and tend to be on the quiet side, you may well find that Birman cats are just the felines for you.
All Birmans have colorpointed features, dark coloration of the face, ears, legs and tail.
Cat image and text coming from www.best-cat-art.com
padding-bottom
规范
Specification | Status | Comment |
---|---|---|
CSS Object Model (CSSOM) View Module offsetWidth |
Working Draft |
备注
offsetWidth
是一个DHTML对象模型中的属性,由微软IE浏览器首次引入。有时候它也可以称为一个元素的物理或图形尺寸,或者<border-box>(译者注:即CSS3中的border-box模型)的宽度。
相关链接
Element.clientWidth
Element.scrollWidth
- Determining the dimensions of elements
- MSDN: offsetWidth Property
- MSDN: Measuring Element Dimension and Location