offsetHeight和clientHeight之间的区别 [英] difference between offsetHeight and clientHeight
问题描述
在javascript dom中 - 一个元素的offsetHeight和clientHeight有什么区别?
In the javascript dom - what is the difference between offsetHeight and clientHeight of an element?
推荐答案
返回对象的可见区域的高度,以像素为单位。该值包含填充的高度,但不包括scrollBar,border和margin。
Returns the height of the visible area for an object, in pixels. The value contains the height with the padding, but it does not include the scrollBar, border, and the margin.
返回对象可见区域的高度,以像素为单位。该值包含padding,scrollBar和边框的高度,但不包括边距。
Returns the height of the visible area for an object, in pixels. The value contains the height with the padding, scrollBar, and the border, but does not include the margin.
所以, offsetHeight
包括滚动条和边框, clientHeight
没有。
So, offsetHeight
includes scrollbar and border, clientHeight
doesn't.
这篇关于offsetHeight和clientHeight之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!