<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body {
margin: 0;
}
#box {
width: 100px;
height: 100px;
margin: 50px;
background-color: red;
border: 10px solid yellow;
padding: 15px;
}
</style>
</head>
<body>
<div id="box">
</div>
<script>
var box = document.getElementById('box');
// clientLeft clientTop分别对应的是border-left、border-top
console.log(box.clientLeft); // 10
console.log(box.clientTop); // 10
// clientWidth clientHeight 包含padding,不包含border
console.log(box.clientWidth); // 130
console.log(box.clientHeight); // 130
</script>
</body>
</html>