方法4,只知道小盒子宽高情况

.box {/* 大盒子高宽未知 */
  width: 400px;
  height: 400px;
  background: #Ccc;
  position: relative;
}

.box1 {/* 小盒子高宽已知 */
  width: 100px;
  height: 100px;
  background: red;
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -50px;
  margin-left: -50px;
}
posted @ 2018-09-25 15:33  指尖下的幽魂  阅读(189)  评论(0编辑  收藏  举报