当前位置:网站首页>监听父元素宽高,自适应插件大小
监听父元素宽高,自适应插件大小
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'));
}
边栏推荐
猜你喜欢
Dart 异常详解
测试工具(四)Jenkins环境搭建与使用
LeetCode 0149. 直线上最多的点数
戴尔PowerEdge服务器R450 RAID配置步骤
从离线到实时对客,湖仓一体释放全量数据价值
从购买服务器到网站搭建成功保姆级教程~超详细
Sound Signal Processing Fundamental Frequency Detection and Time-Frequency Analysis
我三本学历,五面阿里,被面试官“供”着出来了,拿了33*15的Offer
Induction jian hai JustFE 2022/07/29 team, I learned the efficient development summary (years)
数据机构----线性表之单向链表
随机推荐
零代码网站开发利器:WordPress
MVVM项目开发(商品管理系统一)
Solve the problem of page flicker caused by browser scroll bars
sum of special numbers
金山打字通 官网 下载
Matlab simulink particle swarm optimization fuzzy pid control motor pump
"By sharing" northwestern university life service | | bytes a second interview on three sides by HR
I have three degrees, and I have five faces. I was "confessed" by the interviewer, and I got an offer of 33*15.
问下 mysql向pg同步多个表的话 有什么好的方案吗?
ORACLE 实现另外一个用户修改包(package)
Three aspects of Ali: How to solve the problem of MQ message loss, duplication and backlog?
史上超强最常用SQL语句大全
Offer刷题——1
【FiddlerScript】利用FiddlerScript抓包保利威下载
【一句话攻略】彻底理解JS中的回调(Callback)函数
matlab wind speed model wavelet filtering
【翻译】确保云原生通信的安全:从入口到服务网及更远的地方
测试工具(四)Jenkins环境搭建与使用
插入排序—直接插入排序和希尔排序
05-SDRAM:仲裁