重学之JavaScript HTML Element 常用API解析( 三 )


clientWidth
The Element.clientWidth property is zero for inline elements and elements with no CSS; otherwise, it's the inner width of an element in pixels. It includes padding but excludes borders, margins, and vertical scrollbars (if present).
intElemClientWidth is an integer corresponding to the clientWidth of element in pixels. The clientWidth property is read–only.

重学之JavaScript HTML Element 常用API解析

文章插图
 
clientHeight
The Element.clientHeight read-only property is zero for elements with no CSS or inline layout boxes; otherwise, it's the inner height of an element in pixels. It includes padding but excludes borders, margins, and horizontal scrollbars (if present).
clientHeight can be calculated as: CSS height + CSS padding - height of horizontal scrollbar (if present).
This property will round the value to an integer. If you need a fractional value, use element.getBoundingClientRect().

【重学之JavaScript HTML Element 常用API解析】


推荐阅读