h5 上下左右前后居中

.outer {
200px;
height: 200px;
background: red;
position: relative;
}

.inner {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50);
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
}

原文地址:https://www.cnblogs.com/honghong75042/p/12092550.html