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