HTML DOM offsetWidth 属性
https://www.runoob.com/jsref/prop-element-offsetwidth.html
var elmnt = document.getElementById("myDIV"); var txt = "div 元素的高度,包含内边距(padding)和边框(border):" + elmnt.offsetHeight + "px<br>"; txt += "div 元素的宽度,包含内边距(padding)和边框(border):" + elmnt.offsetWidth + "px";