前端开发单位vw和vh

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>前端开发单位vw</title>

  <style>
    *{
      padding: 0;
      margin: 0;

    }
    .root {
      width: 1vw;
      height: 1vh;
      background: red;
    }

  </style>
</head>
<body>
<div class="root"></div>

<script>
  console.log(window.innerWidth,window.innerHeight)
  let oDiv =document.querySelector(".root");

  console.log(getComputedStyle(oDiv).width)
  console.log(getComputedStyle(oDiv).height)

</script>
</body>
</html>

vw和vh介绍

什么是视口:

posted @ 2019-10-08 15:27  前端那点事  阅读(4299)  评论(0编辑  收藏  举报