为什么vertical-align不生效呢?求解为什么没有垂直居中
回答:需要将父元素设置一下行高:可以参考这篇文章:https://blog.csdn.net/qq_43677117/article/details/109475579
<!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>
.one {
width: 400px;
height: 400px;
background-color: red;
margin: 0 auto;
text-align: center;
line-height: 400px;
}
.two {
width: 300px;
height: 300px;
line-height: 300px;
background-color: green;
display: inline-block;
vertical-align: middle;
}
.three {
width: 200px;
height: 200px;
background-color: blue;
display: inline-block;
}
</style>
</head>
<body>
<div class="one">
<div class="two">
<div class="three">
</div>
</div>
</div>
</body>
</html>