CSS版心居中的方法
.container {
display: flex;
justify-content: center;
align-items: center;
}
.container {
position: relative;
}
.centered-content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.container {
display: table;
}
.centered-content {
display: table-cell;
text-align: center;
vertical-align: middle;
}
.container {
display: grid;
place-items: center;
}
.container {
margin-left: auto;
margin-right: auto;
}
.container {
position: relative;
}
.centered-content {
position: absolute;
left: 50%;
transform: translateX(-50%);
}
.container {
position: relative;
}
.centered-content {
position: absolute;
left: calc(50% - [element-width]/2);