直接上代码

 

<!doctype html>
<html lang=”en”>
<head>
<meta charset=”UTF-8”>
<title>fixed</title>
</head>
<style>
div{
position:fixed;
margin:auto;
left:0; right:0; top:0; bottom:0;
width:200px; height:150px;
background: red;
}
</style>
<body>
<div></div>
</body>
</html>