Skip to content

Instantly share code, notes, and snippets.

@jialinhuang00
Last active April 21, 2018 12:56
Show Gist options
  • Save jialinhuang00/b51017610827ec8313936f5d27494bf6 to your computer and use it in GitHub Desktop.
Save jialinhuang00/b51017610827ec8313936f5d27494bf6 to your computer and use it in GitHub Desktop.
各種Height筆記

Element(like div)

clientHeight = padding + height(沒scrollbar)

offsetHeight = padding + border + height

scrollHeight >= clientHeight

Body

clientHeight = padding + height

offsetHeight = padding + border + height

scrollHeight >= clientHeight (firefox, IE)

scrollHeight >= offsetHeight || 視窗可見高度 (chrome)

HTML(documentElement)

clientHeight = 視窗可見高度

offsetHeight = body.offsetHeight + body.margin

scrollHeight >= clientHeight

scrollHeight >= clientHeight (chrome, IE)

IE6 and IE7 suggest that scrollHeight can be shorter than clientHeight

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment