css 使用flexbox中心div

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了css 使用flexbox中心div相关的知识,希望对你有一定的参考价值。

/* unknown width */
.supercenter {
  display: flex;
  justify-content: center;
  align-items: center;
}


/* known width */

.parent {
  display: flex;
  height: 300px; /* Or whatever */
}

.child {
  width: 100px;  /* Or whatever */
  height: 100px; /* Or whatever */
  margin: auto;  /* Magic! */
}

以上是关于css 使用flexbox中心div的主要内容,如果未能解决你的问题,请参考以下文章