方法1:反向移动

  1. position:absolute;  
  2.   top:50%;  
  3.   left: 50%;  
  4.   -webkit-transform: translate(-50%, -50%);  
  5.   transform: translate(-50%, -50%);  

  方法2:flex布局

  1.  display: flex;  
  2.  align-items: center;  
  3.  justify-content: center; 

  方法3:四向定位  

  1. position: absolute;
  2. right: 0;
  3. left: 0;
  4. top: 0;
  5. bottom: 0;
  6. margin: auto;

  方法4:表格

  father{

    display:table;

    text-algin:center;

  }

  son{

    display:table-cell;

    vertical-align:middle;

  }

 

相关文章:

  • 2022-12-23
  • 2021-11-05
  • 2021-11-20
  • 2021-10-14
  • 2022-12-23
  • 2021-07-17
猜你喜欢
  • 2021-05-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2021-07-26
  • 2022-12-23
相关资源
相似解决方案