说明:overflow:scroll的状态
  • 发生溢出的部分只会是内容,padding和border是固定的
  • padding区域的溢出是无法隐藏的。border区域的溢出可以隐藏不可见

        




1.scollHeight:
  • contentHeight + padding + 隐藏的高度
  •  height of an element's content, including content not visible on the screen due to overflow.




2.offsetHeight:
  • 相比clientHeight而言,多包括 border 和水平滚动条的高度


The example image above shows a scrollbar and an offsetHeight which fits on the window.
However, non-scrollable elements may have large offsetHeight values, much larger than the visible content. These elements are typically contained within scrollable elements; consequently these non-scrollable elements may be completely or partly invisible, depending on the scrollTop setting of the scrollable container.
【啥意思?】



3.clientHeight: 内容的最大显示区域
  • clientHeight =  CSS height + CSS padding (不包含水平滚动条的高度和border高度)










1. scrollHeight/clientHeight/offsetHeight的区别

2019-02-17 00:11:04 0 96
这里是评论

相关推荐