获得dom元素的宽度(高度)
<style>
.han {
width: 100px;
height: 120px;
}
</style>
<body>
<div class="han"></div>
</body>
如果dom为内联样式
dom.style.wdith/height
dom.getBoundingClientRect().width/height
let han = document.querySelector('.han')
console.log(han.getBoundingClientRect().width)
dom.offsetHeight/Width
console.log(han.offsetHeight)
window.getComputedStyle(dom).width
console.log(window.getComputedStyle(han).width)
转载请注明原文地址:https://blackberry.8miu.com/read-31650.html