1. 使用定位position: relative脱离文档流,top的偏移量为top: 50%, margin: -元素高度的一半 auto 0 auto;
2. 使用定位position: relative脱离文档流,top的偏移量为top: 50%,使用transform: translateY(-50%);上移元素高度
的一半,margin设置成0 auto,左右居中。
3. 定义元素的宽高,在移动端使用display: flex;align-items: center;justify-content: center;来实现

相关文章:

  • 2022-02-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2021-08-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2021-08-13
  • 2022-12-23
  • 2021-08-29
  • 2022-01-23
相关资源
相似解决方案