当前位置:网站首页>监听父元素宽高,自适应插件大小
监听父元素宽高,自适应插件大小
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'));
}
边栏推荐
猜你喜欢

旋度(7)连接失败localhost8080;连接拒绝了

从底层结构开始学习FPGA(6)----分布式RAM(DRAM,Distributed RAM)

「面经分享」西北大学 | 字节 生活服务 | 一面二面三面 HR 面

sum of special numbers

阿里云李飞飞:中国云数据库在很多主流技术创新上已经领先国外

Introduction to the basic principles, implementation and problem solving of crawler

Dbeaver connect the MySQL database and error Connection refusedconnect processing

Practical training Navicat Chinese and English mode switching

Dart exception details

曲柄滑块机构运动分析和参数优化
随机推荐
零代码网站开发利器:WordPress
uva12326
【视觉SLAM十四讲】第一章理论详解
太厉害了,终于有人能把文件上传漏洞讲的明明白白了
安装SQL Server详细教程
LeetCode 0150. 逆波兰表达式求值
数据湖:数据同步工具NiFi
爬虫基本原理介绍、实现以及问题解决
Data organization -- singly linked list of the linear table
torch
ORACLE modify another user package (package)
05-SDRAM:仲裁
NUMPY
Practical training Navicat Chinese and English mode switching
weight distribution
2022杭电多校第二场1011 DOS Card(线段树)
小白的0基础教程SQL: 关系数据库概述 02
2022.7.26 Mock Competition
阿里云李飞飞:中国云数据库在很多主流技术创新上已经领先国外
05-SDRAM: Arbitration