块级元素的垂直居中

垂直居中

  1. 单行文本垂直居中,设置父元素的line-height为包含块宽度。
  2. 弹性盒设置align-items:center,让弹性项目在侧轴上居中
  3. 相对定位元素,top0bottom0;定高;上下marginauto
  4. 相对定位元素,top50%transformtranslateY(-50%)
原文地址:https://www.cnblogs.com/lee1-w/p/11249970.html