offsetTop, scrollTop
时间: 2023-11-24 11:51:37 浏览: 73
JavaScript之scrollTop、scrollHeight、offsetTop、offsetHeight等属性学习笔记
offsetTop是指某个元素的上边框与其父元素的上边框之间的垂直距离。它是一个只读属性,以像素为单位。\[2\]scrollTop是指某个可滚动区块向下滚动的距离。它是一个方法,可以返回或设置匹配元素的滚动条的垂直位置。如果未设置参数,则返回以像素计的相对滚动条顶部的偏移。\[1\]在给定的例子中,如果为元素t设置了scrollTop属性,内容可能不会完全显示,因为滚动条可能没有滚动到相应的位置。\[3\]
#### 引用[.reference_title]
- *1* *2* [scrollTop及offsetTop的对比](https://blog.csdn.net/jbj6568839z/article/details/86348899)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [JS中offsetTop、clientTop、scrollTop、offsetTop各位置属性详解(含示例图)](https://blog.csdn.net/m0_46833693/article/details/123186078)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文