- 如果是单行文本,父元素的line-height和height设置成同一个值
- 使用
flex
布局,设置为align-item:center
- 绝对定位中设置
bottom:0,top:0
,并设置margin:auto
- 绝对定位中固定高度时设置
top:50%,margin-top
值为高度一半的负值
垂直居中
最新推荐文章于 2024-06-03 18:53:48 发布
flex
布局,设置为align-item:center
bottom:0,top:0
,并设置margin:auto
top:50%,margin-top
值为高度一半的负值