transform translateY(-50%) 实现元素垂直居中效果 在相对的空间内,垂直居中。position: relative;top: 50%;transform: translateY(-50%); 无论内容怎么增加,全文都是垂直居中的。