flex布局 .tag{ display: flex; justify-content: center;/* 水平居中 */ align-items: center;/* 垂直居中 */ line-height: normal;/* 在某些安卓下,垂直居中 */ border: 1px solid red; } 绝对布局 .tag { position: relative; border: 1px solid red; } .text { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); }