.div1 { position:relative; height:100px; width:100px; border:1px solid #ccc; } .div2 { position:absolute; top:0; right:0; bottom:0; left:0; margin:auto; height:50px; width:50px; background:aqua; border:1px solid #ccc; }
使用绝对定位,margin居中