📜  获取元素大小 javascript 代码示例

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

代码示例2
// 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;