垂直居中

行高法

.box{
width: 200px;
height: 60px;
line-height: 60px;
background: #eee;
}

flex法

.box{
height: 120px;
display: flex;
align-items: center;
}

padding法

.box{
padding: 20px 0;
background-color: red;
}

posted @ 2026-04-30 09:36  悲观与乐观  阅读(8)  评论(0)    收藏  举报