第一种:
.parent {
position: relative;
background-color: bisque;
width: 45em;
height: 45em;
display: flex;
justify-content: center;
align-items: center;
}
第二种:
.parent {
position: relative;
background-color: bisque;
width: 45em;
height: 45em;
}
.child {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
第三种:
.parent {
position: relative;
background-color: bisque;
width: 45em;
height: 45em;
}
.child {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
}