Home > Web Front-end > JS Tutorial > body text

js中scrollLeft, scrollTop, scrollWidth, scrollHeigh

WBOY
Release: 2016-06-01 09:54:59
Original
1563 people have browsed it

先用文字介绍一下这四个属性。
scrollLeft 返回当前元素的左边界到它的包含元素的左边界的偏移量。
scrollTop 返回或设置匹配元素的滚动条的垂直位置。
scrollWidth 返回元素的完整的宽度,包括内边距。
scrollHeight 返回元素的完整的高度 ,包括内边距。
 

<code>

<div id="demo" style="border:1px solid red;width:150px; height:200px; margin:10px; padding:20px; overflow:auto;">
先用文字介绍一下这四个属性。
scrollLeft(scrollLeft详解) 返回当前元素的左边界到它的包含元素的左边界的偏移量。
scrollTop(scrollTop详解) 返回或设置匹配元素的滚动条的垂直位置。
scrollWidth(scrollWidth详解) 返回元素的完整的宽度,包括内边距。
scrollHeight(scrollHeight详解) 返回元素的完整的高度 ,包括内边距。
</div>

 </code>
Copy after login

scrollHeight=滚动条可见高度+滚动条不可见高度;
scrollWidth=滚动条可见宽度+ 滚动条不可见宽度。

如图所示:

js中scrollLeft, scrollTop, scrollWidth, scrollHeight分析

js中scrollLeft, scrollTop, scrollWidth, scrollHeight分析

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!