方法3,弹性盒模型

.box {/* 大盒子 */
   400px;
  height: 400px;
  background: #Ccc;
  display: flex;
  justify-content: center;//水平居中
  align-items: center;//垂直居中
}

.box1 {/* 小盒子 */
   200px;
  height: 100px;
  background: red;
}
原文地址:https://www.cnblogs.com/sifeizai/p/9699749.html