方法1,定位,相当于四周受力
.box {/*大盒子*/
width: 400px;
height: 400px;
background: #Ccc;
position: relative;
}
.box1 {/* 小盒子 */
width: 200px;
height: 100px;
background: red;
margin: auto;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
浙公网安备 33010602011771号