当前位置:网站首页>offsetwidth\clientwidth\scrollwidth
offsetwidth\clientwidth\scrollwidth
2022-06-28 16:37:00 【ㄗòs╃牸架】
关于js中的offsetwidth、clientwidth、scrollwidth等一系列属性及其方法一直都傻傻分不清,这里就来总结一下这些方法的用法和含义。
目录
一、clientwidth和clientheigh 、 clienttop和clientleft
二、offsetwidth和offsethight 、 offsettop和offsetleft
三、scrollwidth和scrollheight 、 scrolltop和scrollleft
一、clientwidth和clientheigh 、 clienttop和clientleft
1,clientwidth的实际宽度 clientwidth = width+左右padding
2,clientheigh的实际度 clientheigh = height + 上下padding
3,clienttop的实际宽度 clienttop = boder.top(上边框的宽度)
4,clientleft的实际宽度 clientleft = boder.left(左边框的宽度)
二、offsetwidth和offsethight 、 offsettop和offsetleft
1,offsetwidth的实际宽度
offsetwidth = width + 左右padding + 左右boder
2,offsetheith的实际高度
offsetheith = height + 上下padding + 上下boder
3,offsettop实际宽度
offsettop:当前元素 上边框 外边缘 到 最近的已定位父级(offsetparent) 上边框 内边缘的 距离。如果父级都没有定位,则分别是到body 顶部 和左边的距离
4,offsetleft实际宽度
offsetleft:当前元素 左边框 外边缘 到 最近的已定位父级(offsetparent) 左边框 内边缘的 距离。如果父级都没有定位,则分别是到body 顶部 和左边的距离
三、scrollwidth和scrollheight 、 scrolltop和scrollleft
1,scrollwidth实际宽度
scrollwidth:获取指定标签内容层的真实宽度(可视区域宽度+被隐藏区域宽度)。
2,scrollheight的实际高度
scrollheight:获取指定标签内容层的真实高度(可视区域高度+被隐藏区域高度)
3,scrolltop
scrolltop :内容层顶部 到 可视区域顶部的距离。
4,scrollleft
scrollleft:内容层左端 到 可视区域左端的距离.
注意: 下面元素属性和元素方法都通过 elem.属性 或 elem.方法 的方式使用,window属性通过 window.属性 的方式使用,document属性则通过document调用。
边栏推荐
- StackOverflow 2022 开发者报告:PostgreSQL 超越 MySQL !
- 3. caller service call - dapr
- Super automation and the future of network security
- np tips: random 创建随机矩阵 sample = np.random.random([19, 64 , 64, 3])
- Csp-j1 csp-s1 preliminary training plan and learning points in summer and September 2022
- Fs2k face sketch attribute recognition
- 基于DataWorks的时效仿真平台|得物技术
- Please ask me, the queries written in my database account for 99%. Is it better to use pay as you go mode or reservation mode?
- 使用Karmada实现Helm应用的跨集群部署
- 如何清除 WordPress 中的缓存
猜你喜欢

Design details of the full stack CRM development tool webclient UI workbench

中国SSD行业企业势力全景图

Internet of things cloud convergence Security Guide
![[tcapulusdb knowledge base] tcapulusdb technical support introduction](/img/ae/9295c8ae642cde632d06966c28d342.png)
[tcapulusdb knowledge base] tcapulusdb technical support introduction

解决sqoop出现 ERROR manager.SqlManager: Generic SqlManager.listDatabases() not implemented

Fs2k face sketch attribute recognition

Azure Kinect Microsoft camera unity development summary

After the first failure, AMEC rushed to the Hong Kong stock exchange for the second time, and the financial principal changed frequently

Curve 替换 Ceph 在网易云音乐的实践

AI落地的新范式,就“藏”在下一场软件基础设施的重大升级里
随机推荐
R 编程语言 - 简介
中能融合携手天翼云打造“能源大脑”
QQ appears large-scale number theft, why is this? Is there no solution?
如何登录到你的 WordPress 管理仪表板
3. Caller 服务调用 - dapr
Introduction to reverse commissioning PE structure details 02/07
【TcaplusDB知识库】修改业务修改集群cluster
岛屿类问题通用解法与DFS框架
The first place on the list - brake by wire "new cycle", the market competitiveness of local suppliers is TOP10
Code implementation of gain (4) -- gap dataset missing data filling based on GaN (sequence) [improved version]
apache 设置timeout参数
visio 使用
MySQL self connection query "suggestions collection"
Super detailed steps for MySQL master-slave switching
Tianyi cloud web application firewall (edge cloud version) passed the first batch of trusted authentication
一次简单的反射型XSS操作及思路
运维-- 统一网关非常必要
Lucky draw animation - Carp jumps over the dragon's gate
[force button] 35 Search insert location
[tcaplusdb knowledge base] view tcapdir directory server