.box {
width: 200px;
height: 200px;
border: 1px solid;
display: grid;
align-items: center;
justify-items: center;
}
.box {
width: 200px;
height: 200px;
border: 1px solid;
display: grid;
align-items: center;
justify-content: center;
}
.box {
width: 200px;
height: 200px;
border: 1px solid;
display: grid;
}
p {
margin: auto;
}
.box {
width: 200px;
height: 200px;
border: 1px solid;
display: flex;
align-items: center;
justify-content: center;
}
.box {
width: 200px;
height: 200px;
border: 1px solid;
display: flex;
}
p {
margin: auto;
}
.box {
width: 200px;
height: 200px;
border: 1px solid;
display: table-cell;
vertical-align: middle;
text-align: center;
}
p {
display: inline-block;
}
.box {
width: 200px;
height: 200px;
border: 1px solid;
position: relative;
}
p {
position: absolute;
left: 50%;
top: 50%;
transfrom: translate(-50%, -50%);
margin: 0;
}
.box {
width: 200px;
height: 200px;
border: 1px solid;
text-align: center;
}
.box::after {
content: '';
line-height: 200px;
}
p {
display: inline-block;
}
参考资料