当前位置:网站首页>Get DOM element location information by offset and client
Get DOM element location information by offset and client
2022-04-23 06:53:00 【zjLOVEcyj】
offset Get the width, height and offset of the element
- offsetTop Gets the distance that the upper part of the element is offset from the parent element with positioning , If none of the parent elements are positioned, the relative value is returned body Distance of
- offsetLeft Work with offsetTop
- offsetParent Returns the parent element with the location of the element , If none of the parent elements has a location, return body
- offsetWidth Returns the element width , Include padding, Frame , The width of the content area
- offsetHeight Work with offsetWidth
offset And style The difference between
The most obvious difference is offset The obtained property value is a read-only property , Cannot be used to modify the size and offset of the element itself , Is a numerical value without units
and style The property value obtained is the read-write property , It can be used to modify the size and offset of the element itself
Besides ,style Only the style attributes specified by the element in the inline style can be obtained , and offset You can get the attributes specified by the element in any way
Click the event to obtain the mouse coordinates
- e.pageX You can get the distance from the mouse of the click event to the left of the page
- e.pageY You can get the distance from the mouse of the click event to the top of the page
client Get the element border and width and height
- clientTop Get the top border size
- clientLeft Get the size of the left border
- clientWidth Get the element width , No borders
- clientHeight Get element height , No borders
scroll Get scroll information
- scrollTop Get the upper distance of the element being rolled away
- scrollLeft Returns the distance to the left of the element being rolled away
- scrollWidth Gets the width of the element itself No borders
- scrollHeight Get the height of the element itself No borders And clientHeight The difference is that , When the element content overflows ,scrollHeight Or return the height containing the overflow content , and clientHeight Will not be
Get the scrolling distance of the page
- window.pageXOffset Get the rolling distance on the whole page
- window.pageYOffset Get the right scrolling distance of the whole page
版权声明
本文为[zjLOVEcyj]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230555334067.html
边栏推荐
- C# 监听WMI事件
- leetcode刷题之二进制求和
- .Net Core3.1 使用 RazorEngine.NetCore 制作实体生成器 (MVC网页版)
- 小米摄像头异常解决
- 【代码解析(3)】Communication-Efficient Learning of Deep Networks from Decentralized Data
- New formdata() when importing files
- Router对象、Route对象、声明式导航、编程式导航
- Node data flow
- JS手写兼容性事件绑定
- Kids and COVID: why young immune systems are still on top
猜你喜欢
.NET跨平台原理(上篇)
Leak detection and vacancy filling (II)
Parse PSD files and map them into components
Installing redis using a small leather panel in the window environment
TP5 error reporting variable type error: array solution
Add serial number to El table
ASP.NET CORE JWT认证
1-4 NodeJS的安装之配置可执行脚本
Overview of node file system and buffer
Leetcode刷题之实现strStr()
随机推荐
百度地图案例-修改地图样式
Installing redis using a small leather panel in the window environment
leetcode刷题之二进制求和
Decentralized Collaborative Learning Framework for Next POI Recommendation
时间格式不对,运行sql文件报错
各进制数之间的互相转换
C# 监听WMI事件
1-3 组件与模块
.Net Core3.1 使用 RazorEngine.NetCore 制作实体生成器 (MVC网页版)
【Markdown笔记】
PHP unlimited classification and tree
freeCodeCamp----arithmetic_arranger练习
New formdata() when importing files
WebAPI+Form表单上传文件
TP5 使用redis
并发优化请求
SiteServer CMS5.0使用总结
Solution to page cache problem (use with caution)
Overview of node file system and buffer
freeCodeCamp----shape_calculator练习