手写css弹窗遮罩层

项目需要,涉及到弹窗,所以就手写一个,正好,展示一下我的前端能力。

下面是代码,简洁,直击要害。只需要引入一下jquery的js文件。

效果图:


这是CSS代码:

.cov{
	width:100%;
	height:100%;
	background-color:rgba(0, 0, 0, 0.5);
	z-index:1000;
	display:none;
	position:absolute;
	text-align:center;
	font-size: 16px;
	box-shadow:0px 0px 5px black;
}
.con{
	z-index:1100;
	width:600px;
	height:200px;
	background-color:white;
	position:fixed;
	right:30%;
	top:30%;
	position:fixed;
	box-shadow: 0px 0px 15px black;
}
.ptitle{
	width:100%;
	height:35px;
	background-color:#3daae9;
	color:white;
	line-height:35px;
}
.dbt{
	border-radius: 5px;
    width: 70px;
	height:30px;
	background-color:#3daae9;
	right:20px;
	bottom:20px;
	position:absolute;
	line-height:30px;
	color:white;
}

这是JS代码:

function showCon(){
	$(".cov").show();	
}
function closeCon(){
	$(".cov").hide();	
}

这是HTML:

<div class = "cov">
	<div class = "con">
			<p class = "ptitle">详细信息</p>
			<p>大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好大家好</p>
			<div onclick = "closeCon();" class = "dbt">确定</div>
	</div>
</div>
<button onclick = "showCon();">xxxxxx</button>

写这个就是想帮助一下,那些在找遮罩层代码的 同学,当初我也是焦头烂额的。


  • 6
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值