<div class="parent">
  <div class="children">我是通过flex的水平垂直居中噢!</div>
</div>
html,body{
  width: 100%;
  height: 200px;
}
.parent {
  display:flex;
  align-items: center;/*垂直居中*/
  justify-content: center;/*水平居中*/
  width:100%;
  height:100%;
  background-color:red;
}
.children {
  background-color:blue;
}

 

相关文章:

  • 2022-01-09
  • 2021-08-31
  • 2022-01-05
  • 2021-12-13
  • 2021-10-14
猜你喜欢
  • 2022-12-23
  • 2021-12-24
  • 2021-12-05
相关资源
相似解决方案