代码如下:

<div class="outerContainer">
    <div class="innerContent"></div>
</div>
.outerContainer{
    width:100%;
    height:100%;
    background:#eee;
    display:flex;
    justify-content: center;
    align-items: center;
}
.innerContent{
    width:300px;
    height:300px;
    background: #fff;
    border:1px solid #ccc;
}

效果图:

flex布局实现div的水平垂直居中

相关文章:

  • 2022-02-05
  • 2022-12-23
  • 2021-11-12
  • 2021-06-24
  • 2022-01-05
  • 2021-12-01
  • 2021-05-26
  • 2021-11-30
猜你喜欢
  • 2021-12-24
  • 2021-12-10
  • 2021-08-22
相关资源
相似解决方案