📌  相关文章
📜  如何在 js 中获得具有该边距的高度元素 - Javascript 代码示例

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

代码示例1
//get the margin of an element,
// {{ use the getComputedStyle() method  }}
let box = document.querySelector('div');  // my div
let style = getComputedStyle(box);        // my div style


// all side margin
let marginLeft = parseInt(style.marginLeft);
let marginRight = parseInt(style.marginRight);
let marginTop = parseInt(style.marginTop);
let marginBottom = parseInt(style.marginBottom);