(DOM) offsetHeight、clientHeight 与 scrollHeight

一、图示

图片描述图片描述

二、解释

三者都以px计。

  • offsetHeight:包括内容可见部分的高度,border,可见的padding,水平方向的scrollbar(如果存在);不包括margin。

  • clientHeight:包括内容可见部分的高度,可见的padding;不包括border,水平方向的scrollbar,margin。

  • scrollHeight:包括内容的高度(可见与不可见),padding(可见与不可见);不包括border,margin。

offsetWidth、clientWidth与scrollHeight同理。

三、参考

What is offsetHeight, clientHeight, scrollHeight?

评论

暂无评论