We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
window.scrollY (别名: window.pageYOffset) 返回文档在垂直方向已滚动的像素值, 为了跨浏览器兼容,一般用别名。
window.scrollY (别名: window.pageYOffset)
window.scrollX (别名: window.pageXOffset) 返回文档/页面水平方向滚动的像素值, 为了跨浏览器兼容,一般用别名。
window.scrollX (别名: window.pageXOffset)
window.scroll(x-coord, y-coord) window.scrollTo(x-coord, y-coord) 滚动窗口至文档中的特定位置。
window.scroll(x-coord, y-coord) window.scrollTo(x-coord, y-coord)
clientHeight 和 offsetHeight属性和元素的滚动、位置没有关系, 它代表元素的高度.
clientHeight
offsetHeight
pending
border
margin
inline
当本元素的子元素比本元素高, 且 overflow=scroll 时, 本元素会scroll.
overflow=scroll
scroll
scrollHeight: 代表包括当前不可见部分元素的高度, 可见部分是 clientHeight, scrollHeight>=clientHeight, 单位 px, 只读.
scrollHeight
scrollHeight>=clientHeight
scrollTop: 代表在有滚动条时, 滚动条向下滚动的距离, 即元素顶部被遮住部分的高度. 在没有滚动条时scrollTop=0. 单位 px , 读写(设置scrollTop=0时相当于滚动到顶部).
scrollTop
scrollTop=0
offsetHeight: 包括padding、border、水平滚动条, 但不包括margin的元素高度. 对于inline元素这个属性一直是0, 单位 px, 只读.
padding
offsetTop: 当前元素顶部距离最近父元素顶部的距离, 与滚动条没有关系. 单位 px, 只读.
offsetTop
The text was updated successfully, but these errors were encountered:
No branches or pull requests
与scroll相关的方法
window对象下:
window.scrollY (别名: window.pageYOffset)
返回文档在垂直方向已滚动的像素值, 为了跨浏览器兼容,一般用别名。window.scrollX (别名: window.pageXOffset)
返回文档/页面水平方向滚动的像素值, 为了跨浏览器兼容,一般用别名。window.scroll(x-coord, y-coord) window.scrollTo(x-coord, y-coord)
滚动窗口至文档中的特定位置。Element对象下:
clientHeight
: 包括pending
但不包括border
、水平滚动条、margin
的元素高度.对于inline
的元素这个属性一直是0, 单位 px, 只读.当本元素的子元素比本元素高, 且
overflow=scroll
时, 本元素会scroll
.scrollHeight
: 代表包括当前不可见部分元素的高度, 可见部分是clientHeight
,scrollHeight>=clientHeight
, 单位 px, 只读.scrollTop
: 代表在有滚动条时, 滚动条向下滚动的距离, 即元素顶部被遮住部分的高度. 在没有滚动条时scrollTop=0
. 单位 px , 读写(设置scrollTop=0
时相当于滚动到顶部).HTMLElement对象下:
offsetHeight
: 包括padding
、border
、水平滚动条, 但不包括margin
的元素高度. 对于inline
元素这个属性一直是0, 单位 px, 只读.offsetTop
: 当前元素顶部距离最近父元素顶部的距离, 与滚动条没有关系. 单位 px, 只读.The text was updated successfully, but these errors were encountered: