我正在尝试将文字置于此angular material card
中心当前它以水平为中心,但我希望它垂直居中
HTML:
<mat-card class="card-initials">
<div>
BD
</div>
</mat-card>
CSS:
.card-initials{
width: 200px;
height: 200px;
float: right;
margin: 15px;
}
.card-initials div{
width: inherit;
height: inherit;
display: flex;
justify-content: center;
align-content: center;
}
见下目前的样子:
答案 0 :(得分:3)
添加align-items:center
.card-initials div{
width: inherit;
height: inherit;
display: flex;
justify-content: center;
align-content: center;
align-items:center
}
答案 1 :(得分:2)
您可以使用line-height:200px
:
.card-initials div{
width: inherit;
height: inherit;
display: flex;
justify-content: center;
align-content: center;
line-height:200px;
}