display:-webkit-box;的语法,-webkit-box-orient: vertical;垂直方向,
当子元素A用-webkit-box-flex: 1;自适应了,元素A有个子元素B高度100%;发现元素B高度为0,明明元素A已经有高度了啊,为什么元素B没有。
而且发现最新的flex语法则没有问题。
下面是代码(旧语法有这个问题,新语法没有):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.box {
height: 100vh;
display: -webkit-box;
-webkit-box-orient: vertical;
/* display: flex;
flex-direction: column; */
}
p {
width: 100px;
height: 100px;
background-color: black;
color: #ffffff;
}
.bot {
background-color: darkgoldenrod;
padding: 5px;
-webkit-box-flex: 1;
/* flex: 1; */
}
.ddd {
width: 100%;
height: 100%;
background-color: darkblue;
}
</style>
</head>
<body>
<div class="box">
<p>W S </p>
<div class="bot">
<div class="ddd"></div>
</div>
</body>
</html>