css 垂直居中 1、子控件添加css样式 position: relative; top: 50%; transform: translateY(50%); /*垂直居中*/ margin: 0 auto; /* 水平居中 */ 2、使用flex的话 直接在父布局处理即可 display: flex; align-items: center; /* 垂直居中 */ justify-content: center; /* 水平居中 */