当前位置:网站首页>监听父元素宽高,自适应插件大小
监听父元素宽高,自适应插件大小
2022-08-01 06:52:00 【原莱_】
参考文档:ResizeObserver
通常用于第三方插件宽高适应:echarts/antv等
//监听对象变化回调
const resizeObserver = new ResizeObserver(entries => {
for (let entry of entries) {
if(entry.contentBoxSize) {
const width = document.getElementById('fatherbox').clientWidth
const height = document.getElementById('fatherbox').clientHeight
document.getElementById('sonbox').style.width = width
}
}
});
//初始化注册监听对象
const init = () => {
resizeObserver.observe(document.getElementById('fatherbox'));
}
边栏推荐
- 05-SDRAM: Arbitration
- first unique character in characters
- Guest brush SQL - 2
- LeetCode Question of the Day (309. Best Time to Buy and Sell Stock with Cooldown)
- NIO编程
- 小白的0基础教程SQL: 什么是SQL 01
- mysql中添加字段的相关问题
- Induction jian hai JustFE 2022/07/29 team, I learned the efficient development summary (years)
- Win任务栏图标异常解决
- LeetCode 0150. 逆波兰表达式求值
猜你喜欢

太厉害了,终于有人能把文件上传漏洞讲的明明白白了

Guest brush SQL - 2

first unique character in characters

零代码网站开发利器:WordPress

Dialogue with the father of MySQL: One excellent programmer is worth 5 ordinary programmers

测试工具(四)Jenkins环境搭建与使用

matlab simulink 粒子群优化模糊pid控制的电机泵

数据机构----线性表之单向链表

点餐系统数据库设计--SQL Server
![Explosive 30,000 words, the hardest core丨Mysql knowledge system, complete collection of commands [recommended collection]](/img/7f/08b323ffc5b5f8e3354bee6775b994.png)
Explosive 30,000 words, the hardest core丨Mysql knowledge system, complete collection of commands [recommended collection]
随机推荐
NIO编程
第02章 MySQL的数据目录【1.MySQL架构篇】【MySQL高级】
奇葩问题 npm install 报错 gyp ERR
Explosive 30,000 words, the hardest core丨Mysql knowledge system, complete collection of commands [recommended collection]
[Translation] Securing cloud-native communications: From ingress to service mesh and beyond
Induction jian hai JustFE 2022/07/29 team, I learned the efficient development summary (years)
Windows taskbar icon abnormal solution
uva10825
Bean的生命周期
「游戏引擎 浅入浅出」4.1 Unity Shader和OpenGL Shader
leetcode43 string multiplication
leetcode125 Verify palindrome string
上课作业(7)——#598. 取余运算(mod)
滚动条样式修改
史上超强最常用SQL语句大全
LeetCode 0150. Reverse Polish Expression Evaluation
仿牛客网讨论社区项目—项目总结及项目常见面试题
小程序通过云函数操作数据库【使用get取数据库】
matlab simulink 粒子群优化模糊pid控制的电机泵
Practical training Navicat Chinese and English mode switching