当前位置:网站首页>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^)\\\~~~
谢谢各位读者们啦(^_^)∠※!!!

边栏推荐
- ES6中 async 函数、await表达式 的基本用法
- 神经网络(ANN)
- Detailed explanation of 9 common reasons for MySQL index failure
- Preparations for web vulnerabilities
- 【Multithreading】
- 【深入浅出玩转FPGA学习14----------测试用例设计2】
- MySQL的grant语句
- Go study notes (84) - Go project directory structure
- XSS相关知识
- [Deep learning] Detailed explanation of Transformer model
猜你喜欢

C language force buckles the rotating image of the 48th question.auxiliary array

SWM32 Series Tutorial 6 - Systick and PWM

h264和h265解码上的区别

How to adjust Chinese in joiplay simulator

Shell编程之条件语句

Niuke.com question brushing training (4)

Mini Program - Global Data Sharing

How to solve types joiplay simulator does not support this game

IOT跨平台组件设计方案

MySQL数据库面试题总结(2022最新版)
随机推荐
Optimization of aggregate mentioned at DATA AI Summit 2022
Summary of MySQL database interview questions (2022 latest version)
ELK部署脚本---亲测可用
Filter (Filter)
SWM32系列教程6-Systick和PWM
[Deep learning] Detailed explanation of Transformer model
MPI简谈
Kotlin协程:协程上下文与上下文元素
Adding, deleting, modifying and checking the foundation of MySQL
How to use joiplay emulator
作业:iptables防止nmap扫描以及binlog
Jetpack Compose学习(8)——State及remeber
MySQL筑基篇之增删改查
go mode tidy出现报错go warning “all“ matched no packages
MySQL Series 1: Account Management and Engine
MySQL notes under
How to import game archives in joiplay emulator
[In-depth and easy-to-follow FPGA learning 15---------- Timing analysis basics]
How to adjust Chinese in joiplay simulator
xss的绕过