<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
position:fixed;
width: 500px;
height: 400px;
background-color: brown;
top: 50%;
left: 50%;
margin-left: -250px;
margin-top: -200px;
}
.box .login {
width: 300px;
}
</style>
</head>
<body>
<div class="box">
<div class="login">
<!-- <form action="">
<label for="">用户名
<input type="text">
</label>
<label for="">
<input type="password" name="" id="">
</label>
<button>登录</button>
</form> -->
</div>
</div>
</body>
</html>
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200720080623475.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3hpYW9oYWl6aTE1,size_16,color_FFFFFF,t_70)
2 遮层不能点击事件
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.outer{
position: fixed;
width: 100%;
height: 100%;
background: rgba(0,0,0,.5);
top: 0px;
left: 0px;
}
.outer .box{
position: absolute;
width: 400px;
height: 300px;
background: cornflowerblue;
left:50%;
top:50%;
margin-left: -200px;
margin-top: -150px;
}
</style>
</head>
<body>
<ul>
<li><a href="pageCenter.html">xxxxx</a></li>
</ul>
<div class="outer">
<div class="box">
</div>
</div>
</body>
</html>
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200720080732697.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3hpYW9oYWl6aTE1,size_16,color_FFFFFF,t_70)