hasher
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        div {
            width: 100px;
            height: 100px;
            padding: 10px;
            border: 10px solid #000;
            margin: 100px;
            background-color: pink;
        }
    </style>
</head>
<body>
 
    <div class="box"></div>
 
<script>
 
    var div = document.getElementsByTagName("div")[0];
 
    //offsetHeight和offsetWidth: 可以检测盒子的宽高。
    //包括宽高本身,padding,border。不包括margin
 
    //offsetHeight = height+padding+border;(不加margin)
    //offsetWidth = width+padding+border;(不加margin)
 
    console.log(div.offsetHeight);
    console.log(typeof div.offsetHeight);   //number
 
</script>
 
 
</body>
</html>

分类:

技术点:

相关文章:

  • 2021-07-25
  • 2022-12-23
  • 2021-09-11
  • 2021-11-08
  • 2021-11-30
  • 2022-01-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-12
  • 2021-09-17
  • 2021-12-19
  • 2021-11-21
  • 2021-05-03
相关资源
相似解决方案