方法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;
}
posted @ 2018-09-25 15:25  指尖下的幽魂  阅读(204)  评论(0)    收藏  举报