运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!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>The Element Object</h1> <h2>The clientTop and clientLeft Properties</h2> <p>Display the width of myDIV's top and left border:</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>