原声js点击显示遮罩层

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>遮罩层</title>
</head>
<style>
.bigbox{
	width: 100%;
	height:100%;
	position: absolute;
	left: 0px;
	top: 0px;
	z-index: 100;
}
.showbox{
	display: none;
	width:100%;
	z-index: 101;
	height: 100%;
	background-color: #000;
	/*opacity: 0.2;*/
	background: rgba(0,0,0,0.3);
	position: absolute;
	top: 0px;
	left: 0px;
}
.tanchu{
	text-align: center;
	z-index: 120;
	display: none;
	width:400px;
	height:200px;
	border:solid 1px pink;
	background-color: #fff;
	position: absolute;
	top: 40%;
	left: 40%;
}
.box2{
	text-align: center;
	width: 400px;
	height: 400px;
	margin: 100px auto;
    border:2px solid #000;
}
#btn{
	margin-top: 50px;
	border:0px solid red;
	width: 100px;
	height: 40px;
	background-color:pink; 
}
.wb{
	width: 200px;
	height: 200px;
	border:1px solid pink;
	margin: 10px auto;
}
.show{
	display: block;
}
.hide{
	display: none;
}
</style>
<body>
<div class="bigbox">
<div class="box2">
<input type="button" value="点击我看看" id="btn">
<div class="wb"></div>
</div>
  <div class="showbox" id="show"></div>
  <div class="tanchu" id="info">
 <p>展示的内容信息</p>
 <button id="close">关闭</button>
  </div>
</div>
<script>
var btn=document.getElementById('btn');
var show=document.getElementById('show');
var info=document.getElementById('info');
var close=document.getElementById('close');
btn.function(){
	info.classList.add('show');
	show.classList.add('show');
}
close.function(){
	info.classList.add('hide');
	show.classList.add('hide');
}

</script>
</body>
</html>

实现动态效果
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值