Get the width of myDIV's top and left border:
const element = document.getElementById("myDIV");
let text = "clientTop: " + element.clientTop + "px<br>";
text += "clientLeft: " + element.clientLeft + "px";
Try it Yourself »
The clientTop
property returns the width of the top border of an element, in pixels.
The clientTop
property does not include the element's top padding or top margin.
The clientTop
property is read-only.
The style.borderTopWidth Property also returns the width of an element's top border.
element.clientTop
Type | Description |
Number | The width of an element's top border, in pixels. |
element.clientTop
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!