<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <style> * { margin: 0; padding: 0; } div { border: 10px solid #000; width: 200px; height: 200px; background-color: red; margin: 20px; padding: 20px; } </style> </head> <body> <div></div> <script> var aDiv = document.getElementsByTagName("div")[0]; console.log(aDiv.style.width); console.log(aDiv.scrollWidth); console.log(aDiv.offsetWidth); </script> </body> </html>
3046742
相关分类