js获取盒模型
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
#app{
width: 100px;
height: 100px;
border: 5px solid black;
margin: 10px;
padding: 15px;
background-color: #0088DD;
}
</style>
</head>
<body>
<div id="app">
</div>
</body>
<script type="text/javascript">
let box = document.getElementById('app')
let w = window.getComputedStyle(box,null).width
console.log(w)
console.log('clientWidth' + app.clientWidth + 'px')
console.log('clientHeight' + app.clientHeight + 'px')
console.log('offset')
console.log('offsetWidth' + app.offsetWidth + 'px')
console.log('offsetHeight' + app.offsetHeight + 'px')
</script>
</html>
![在这里插入图片描述](https://img-blog.csdnimg.cn/2021012007414371.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NTg5MTE0Ng==,size_16,color_FFFFFF,t_70#pic_center)