方法一(宽高不固定)
.box{
width: 600px;
height: 400px;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
方法二(宽高固定)
.box{
width: 600px;
height: 400px;
position: absolute;
left: 50%;
top: 50%;
margin-top:-200px;
margin-left:-300px;
}
方法三(不定宽高)
.box{
position: absolute;
left: 0;
top: 0;
right:0;
bottom:0;
margin:auto;
}
方法四(不定宽高)
.box{
display:flex;
justify-content: center;
align-items: center;
}
方法五(不定宽高)
.box{
display: table-cell;
vertical-align: middle;
text-align: center;
}
//子节点
.box-item{
display:inline-block;
}