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

边栏推荐
- 【深度学习】Transformer模型详解
- Adding, deleting, modifying and checking the foundation of MySQL
- 【愚公系列】2022年07月 Go教学课程 017-分支结构之IF
- xss绕过:prompt(1)
- XSS相关知识
- Consistency and Consensus of Distributed Systems (1) - Overview
- DNS resolution process [visit website]
- 场景之多数据源查询及数据下载问题
- MySQL notes under
- Oracle has a weird temporary table space shortage problem
猜你喜欢

pytorch bilinear interpolation

binglog日志追踪:数据备份并备份追踪

encrypted transmission process

How to Repair Word File Corruption

MySQL grant statements

Summary of MySQL database interview questions (2022 latest version)

加密传输过程

Error ER_NOT_SUPPORTED_AUTH_MODE Client does not support authentication protocol requested by serv

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

软件开发设计流程
随机推荐
【愚公系列】2022年07月 Go教学课程 013-常量、指针
乌克兰外交部:乌已完成恢复粮食安全出口的必要准备
.NET 跨平台应用开发动手教程 |用 Uno Platform 构建一个 Kanban-style Todo App
(五)fastai应用
MySQL中substring与substr区别
Mini Program - Global Data Sharing
Detailed explanation of 9 common reasons for MySQL index failure
MySQL master-slave replication and read-write separation script - pro test available
Adding, deleting, modifying and checking the foundation of MySQL
正则表达式密码策略与正则回溯机制绕过
Steven Giesel recently published a 5-part series documenting his first experience building an application with the Uno Platform.
Shell programming of conditional statements
[In-depth and easy-to-follow FPGA learning 15---------- Timing analysis basics]
pytorch bilinear interpolation
[C language course design] C language campus card management system
Asser uses ant sword to log in
xss的绕过
消息队列存储消息数据的MySQL表设计
background对float的子元素无效
Add text watermark to PHP image