vw 和 百分比的區別


  1. vw就是view width,可視寬度,所以一般來說都是可是窗口的一半.
  2. 百分比的寬度,就是自己父元素寬度的一半了.
    image
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .container {
        width: 800px;
        height: 200px;
        background-color: blueviolet;
      }
      .box {
        height: 100px;
        background-color: yellowgreen;
      }
      .box2 {
        height: 100px;
        background-color: red;
      }
      .box {
        width: 50%;
      }
      .box2 {
        width: 50vw;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="box"></div>
      <div class="box2"></div>
    </div>
  </body>
</html>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM