offsetHeight和clientHeight之间的区别 [英] difference between offsetHeight and clientHeight

查看:281
本文介绍了offsetHeight和clientHeight之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在javascript dom中 - 一个元素的offsetHeight和clientHeight有什么区别?

In the javascript dom - what is the difference between offsetHeight and clientHeight of an element?

推荐答案

clientHeight


返回对象的可见区域的高度,以像素为单位。该值包含填充的高度,但不包括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.

offsetHeight


返回对象可见区域的高度,以像素为单位。该值包含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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆