简易弹窗遮罩层

遮罩层弹窗经常用到,记录一下

HTML代码

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>弹窗</title>
	</head>
	<body>
		<div id="showBtn">点击出现</div>
		<div id="popup">
		    <div class="popup">
		        <div id="case">
		            <p class="txt">弹窗</p>
					<p class="btnBox"><button class="btn">确定</button></p>	            
		        </div>
		    </div>
		</div>
	</body>
</html>


css代码

			#popup {
			    display: none;
			}
			.popup{
			    position: absolute;
			    height: 100%;
			    width: 100%;
			    top: 0;
			    left: 0;
			    background-color: rgba(90, 90, 90, 0.5);
			    z-index: 1;
			    display:flex;
			    flex-direction:row;
			    justify-content:center;
			    align-items:center;
			}
			#case {
			    width:80%;
			    height:298px;
			    border-radius:16px;
				background: #fff;
			    z-index:2;
				display: flex;
				flex-direction:column;
				justify-content:center;
				align-items:center;
			}
			#case .txt{
			    width:80%;
			    height:50%;
			    font-size:32px;
			    color:rgba(51,51,51,1);
				display: flex;
				flex-direction:row;
				justify-content:center;
				align-items:center;
			}
			.btnBox{
				width:100%;
				height:50%;
				display: flex;
				flex-direction:row;
				justify-content:center;
				align-items:center;
			}
			#case .btn{
			    width:80%;
			    height:100%;
			    background:rgba(255,255,255,1);
			    border:2px solid rgba(238,238,238,1);
			    box-shadow:0px 2px 0px 0px rgba(238,238,238,1);
			    border-radius:16px;
			    font-size:32px;
			    color:rgba(54,186,26,1);
				display: flex;
				flex-direction:row;
				justify-content:center;
				align-items:center;
			}
			#showBtn{
				width: 100px;
				height: 100px;
				background: #1E8DFF;
				margin: auto;
			}

js

	 var popup = $("#popup")[0];
	$("#showBtn").on("click",()=>{
		popup.style.display= "block";
	})
	$(".btn").on("click",()=>{
		popup.style.display= "none";
	})

简单的弹窗遮罩层就完成了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值