弹出层案例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="keywords" content="">
<meta name="description" content="">
<title></title>
<style>
input{
width: 400px;
height: 100px;
background-color: pink;
color: #fff;
font-size: 50px;
}
#cover{
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.3);
}
#box{
position: absolute;
top: 0;
left: 0 ;
bottom: 0;
right: 0;
margin: auto;
width: 500px;
height: 300px;
background-color: #58a;
color: #fff;
font-size: 100px;
line-height: 300px;
text-align: center;
}
</style>
</head>
<body>
<input type="button" value="点我弹出内容">
<div id="wrap">
随便写点内容<br>
随便写点内容<br>
随便写点内容<br>
随便写点内容<br>
随便写点内容<br>
随便写点内容<br>
随便写点内容<br>
随便写点内容<br>
随便写点内容<br>
随便写点内容<br>
随便写点内容<br>
随便写点内容<br>
</div>
<div id="cover">
<div id="box">弹窗</div>
</div>
<script>
let button = document.querySelector("input"),
cover = document.getElementById("cover"),
box = document.getElementById("box");
button.onclick = function(){
cover.style.display = "block";
};
box.onclick = function(){
cover.style.display = "none";
};
button.style.cssFloat = "left";
button.style.styleFloat = "left";
</script>
</body>
</html>