<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
font-size: 13pt;
}
#bg{
position: absolute;
top:0;
left: 0;
width: 100%;
height: 100%;
background-color:rgba(0,0,0,0.5);
display: none;
}
#box{
width: 260px;
position: absolute;
z-index: 2;
left: 50%;
margin-left: -130px;
top:50%;
margin-top:-75px;
background-color: #fff;
}
#box .title{
background-color: #008081;
color:#fff;
padding: 10px 20px;
}
#box .con{
overflow: hidden;
}
#box .con .img{
margin: 10px;
float: left;
}
#box .con .rright{
float: left;
margin-bottom: 20px;
}
#box .con .rright .btn{
text-align: center;
}
#box .con .rright .btn>button{
width: 80px;
height: 30px;
font-size: 20px;
border: none;
background-color: #008081;
color:#fff;
}
</style>
</head>
<body>
<button id="btnShow">弹框</button>
<div id="bg">
<!-- 定义一个弹窗 -->
<div id="box">
<div class="title">
提示
</div>
<div class="con">
<div class="img">
<img width="100px" src="img/gantanhao.png" alt="">
</div>
<div class="rright">
<p>你真的要删除吗?</p>
<div class="btn">
<button id="cls">确定</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<script>
var btnShow = document.getElementById("btnShow");
btnShow.onclick = function(){
var bg = document.getElementById("bg");
var box = document.getElementById("box");
bg.style.display = 'block';
box.style.display = 'block';
}
var btnCls = document.getElementById("cls");
btnCls.onclick = function(){
bg.style.display = 'none';
box.style.display = 'none';
}
</script>
css html js 自定义弹窗
最新推荐文章于 2024-05-09 15:49:59 发布