让 div 水平并垂直居中(方法 1~6)下
作者:互联网
方法五
给父标签tent-alian:center;line-height:父标签的高;给子标签display:inline-block;vertical-align:middle;给予标签旁边添加空span
方法六
<style>
.small {
width: 100px;
height: 100px;
background-color: #f00;
grid-area: a;
}
.box {
width: 300px;
height: 300px;
border: 1px solid #000;
margin: 200px auto;
display: grid;
grid-template-rows: 100px 100px 100px;
grid-template-columns: 100px 100px 100px;
grid-template-areas: ". . ." ". a ." " . . . ";
}
</style>
<div class="box">
<div class="small"></div>
</div>
标签:居中,标签,100px,height,垂直,width,grid,template,div 来源: https://blog.csdn.net/APLL_/article/details/123240085