当前位置:网站首页>DOM系列之 offset 系列
DOM系列之 offset 系列
2022-07-31 00:35:00 【老__L】
1、offset系列
offset 翻译过来就是偏移量, 我们使用 offset系列相关属性可以动态的得到该元素的位置(偏移)、大小等。
2、offset系列的属性


3、描述
1.获得元素距离带有定位父元素的位置
2.获得元素自身的大小(宽度高度)
3.注意:返回的数值都不带单位
4、offset 与 style 区别
4.1、offset
- offset 可以得到任意样式表中的样式值
- offset 系列获得的数值是没有单位的
- offsetWidth 包含padding+border+width
- offsetWidth 等属性是只读属性,只能获取不能赋值
- 所以,我们想要获取元素大小位置,用 offset 更合适
4.2、style
- style 只能得到行内样式表中的样式值
- style.width 获得的是带有单位的字符串
- style.width 获得不包含 padding 和 border 的值
- style.width 是可读写属性,可以获取也可以赋值
- 所以,我们想要给元素更改值,则需要用style改变
后记
如果你感觉文章不咋地
//(ㄒoㄒ)//,就在评论处留言,作者继续改进;o_O???
如果你觉得该文章有一点点用处,可以给作者点个赞;\\*^o^*//
如果你想要和作者一起进步,可以微信扫描二维码,关注前端老L;~~~///(^v^)\\\~~~
谢谢各位读者们啦(^_^)∠※!!!

边栏推荐
- 【深入浅出玩转FPGA学习13-----------测试用例设计1】
- How to install joiplay emulator rtp
- Kotlin协程:协程上下文与上下文元素
- asser利用蚁剑登录
- 从笔试包装类型的11个常见判断是否相等的例子理解:包装类型、自动装箱与拆箱的原理、装箱拆箱的发生时机、包装类型的常量池技术
- WEB Security Basics - - - Vulnerability Scanner
- SereTOD2022 Track2 Code Analysis - Task-based Dialogue Systems Challenge for Semi-Supervised and Reinforcement Learning
- 【ABAP】MFBF过账到质量检验库存类型Demo
- binglog日志追踪:数据备份并备份追踪
- MySQL数据库的truncate与delete区别
猜你喜欢

【深入浅出玩转FPGA学习15----------时序分析基础】

In-depth understanding of the auto-increment operator from two error-prone written test questions

MySQL数据库面试题总结(2022最新版)

不用Swagger,那我用啥?

Homework: iptables prevent nmap scan and binlog

Error ER_NOT_SUPPORTED_AUTH_MODE Client does not support authentication protocol requested by serv

unity2D横版游戏教程4-物品收集以及物理材质

封装、获取系统用户信息、角色及权限控制

web漏洞之需要准备的工作

Asser uses ant sword to log in
随机推荐
background has no effect on child elements of float
[C language course design] C language campus card management system
Error ER_NOT_SUPPORTED_AUTH_MODE Client does not support authentication protocol requested by serv
MySQL database (basic)
Thesis understanding: "Designing and training of a dual CNN for image denoising"
Summary of MySQL database interview questions (2022 latest version)
正则表达式密码策略与正则回溯机制绕过
【Yugong Series】July 2022 Go Teaching Course 013-Constants, Pointers
go mode tidy出现报错go warning “all“ matched no packages
MySQL grant statements
How to adjust Chinese in joiplay simulator
Strict Mode for Databases
encrypted transmission process
binglog log tracking: data backup and backup tracking
Oracle一个诡异的临时表空间不足的问题
Optimization of aggregate mentioned at DATA AI Summit 2022
Go study notes (84) - Go project directory structure
What is Promise?What is the principle of Promise?How to use Promises?
How to Repair Word File Corruption
h264和h265解码上的区别