CSS真的是反反复复看! 温故而知新
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>固定宽度高度的垂直居中</title>
<style>
.center {
height: 200px;
width:300px;
border: 3px solid green;
position: absolute;
top:50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.center p {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<div class="center">
<p>我是水平和垂直居中的。</p>
</div>
</body>
</html>