- vw就是view width,可视宽度,所以一般来说都是可是窗口的一半.
- 百分比的宽度,就是自己父元素宽度的一半了.
<!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>