📌  相关文章
📜  获取 dom 元素 js 的宽度 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:07.362000             🧑  作者: Mango

代码示例1
// Get Content + Padding + Border
let box = document.querySelector('div');
let width = box.offsetWidth;
let height = box.offsetHeight;

// Get Content + Padding only
let box = document.querySelector('div');
let width = box.clientWidth;
let height = box.clientHeight;