其他分享
首页 > 其他分享> > vw 和 百分比的区别

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>

标签:百分比,区别,color,100px,height,width,background,vw
来源: https://www.cnblogs.com/zhuoss/p/16080113.html