一、绝对定位
#box {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
<div id="box"></div>
二、也得绝对定位,?
#box {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
<div id="box"></div>

4677

被折叠的 条评论
为什么被折叠?



