x
 
<!DOCTYPE html>
<html>
<style>
#myDIV {
  height: 250px;
  width: 400px;
  padding: 10px;
  margin: 15px;
  border-top: 15px solid black;
  border-left: 10px solid red;
  background-color: lightblue;
}
</style>
<body>
<h1>Element 对象</h1>
<h2>clientTop 和 clientLeft 属性</h2>
<p>显示 myDIV 的上边框和左边框的宽度:</p>
<div id="myDIV">
  <p id="demo"></p>
</div>
<script>
const element = document.getElementById("myDIV");
let text = "clientTop: " + element.clientTop + "px<br>";
text += "clientLeft: " + element.clientLeft + "px";
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>