CSS 实现水平垂直居中的方式分为两种情况:
居中元素定宽高
居中元素不定宽高
.wp { position: relative; } .box { position: absolute;; top: 50%; left: 50%; margin-left: -50px; margin-top: -50px; }