正如您在下面的演示中所看到的,margin: auto;将蓝色div水平居中,而不是垂直居中.为什么不?
.box {
border: 1px solid red;
width: 100px;
height: 100px;
}
.center {
background: blue;
width: 50px;
height: 50px;
margin: auto;
}Run Code Online (Sandbox Code Playgroud)
<div class="box">
<div class="center"></div>
</div>Run Code Online (Sandbox Code Playgroud)
我的问题不是要求解决方法.