<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>center</title>
<style>
.div1{
width: 200px;
height: 200px;
border:1px solid red;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
overflow: auto;
margin: auto;
}
.div2{
width: 200px;
height: 200px;
background:black;
display: table-cell;
vertical-align: middle;
text-align: center;
}
.div2 span{
color: white;
}
</style>
</head>
<body>
<div class="div1"></div>
<div class="div2">
<span>实现文字垂直居中</span>
</div>
</body>
</html>