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

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

.box1 {/* 小盒子高宽已知 */
   100px;
  height: 100px;
  background: red;
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -50px;
  margin-left: -50px;
}
原文地址:https://www.cnblogs.com/sifeizai/p/9699769.html