<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>水平、垂直居中Div</title>
<meta charset="utf-8" />
<style>
.CenterBox {
position: fixed;
top: 40%;
left: 50%;
background-color: #eee;
border-radius: 15px;
padding: 15px;
width: 350px;
-webkit-transform: translateX(-50%) translateY(-50%);
-moz-transform: translateX(-50%) translateY(-50%);
-ms-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
</style>
</head>
<body>
<div class="CenterBox">
asd
</div>
</body>
</html>