div水平垂直居中显示
绝对定位div,top和left设置为50%.
margin-top为 1/2 * height;margin-left为 1/2 * width
.center{
 width:200px;
 height:150px;
 background-color:#0066CC;
 position:absolute;top:50%;left:50%;
 margin-top:-75px;
 margin-left:-100px;
}
.center2{
margin-left: auto;
margin-right: auto;
}
<div class="center"></div>

相关文章:

  • 2021-10-29
  • 2021-08-28
  • 2021-06-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-21
  • 2022-01-05
  • 2022-12-23
  • 2021-12-01
  • 2021-11-06
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案