项目需要,涉及到弹窗,所以就手写一个,正好,展示一下我的前端能力。
下面是代码,简洁,直击要害。只需要引入一下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>
写这个就是想帮助一下,那些在找遮罩层代码的 同学,当初我也是焦头烂额的。