<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>CSS---定位实例练习---相对于浏览器窗口水平垂直居中的弹框</title>
<style type="text/css">
body{
margin: 0;
}
.menu{
height: 80px;
background-color: #00FFFF;
position: fixed;
width: 960px;
top: 0px;
left: 50%;
margin-left:-480px;
}
.popop{
width: 500px;
height: 300px;
border: 1px solid #00FFFF;
background-color: deeppink;
position: fixed;
left: 50%;
margin-left:-251px;
top: 50%;
margin-top: -150px;
z-index: 9999;
}
.popop h2{
background-color: cornflowerblue;
margin: 10px;
height: 40px;
}
p{
text-align: center;
}
.mask{
position: fixed;
width: 100%;
height: 100%;
background-color: black;
top: 0;
left: 0;
opacity: 0.5;
z-index: 9998;
}
.pop_con{
display: block;
}
</style>
</head>
<body>
<div id="" class="menu">
菜单文字
</div>
<div id="" class="pop_con">
<div class="popop">
<h2>弹框标题</h2>
</div>
<div id="" class="mask">
</div>
</div>
<p>文章文字</p>
<br>
<br>
<br>
<p>文章文字</p>
<br>
<br>
<br>
<p>文章文字</p>
<br>
<br>
<br>
<p>文章文字</p>
<br>
<br>
<br>
<p>文章文字</p>
<br>
<br>
<br>
<p>文章文字</p>
<br>
<br>
<br>
<p>文章文字</p>
<br>
<br>
<br>
<p>文章文字</p>
<br>
<br>
<br>
<p>文章文字</p>
<br>
<br>
<br>
</body>
</html>