超级简单的模拟弹窗
<!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>模拟框案例</title>
<style>
*{
padding: 0;
margin: 0;
}
body {
background-color: aliceblue;
position: relative;
}
#div {
width: 100%;
height: 800px;
}
#div h1{
text-align: center;
font-size: 100px;
font-weight: 100;
color: #000;
display: block;
}
#divs {
width: 700px;
height: 500px;
background-color: beige;
border-radius: 5px ;
box-shadow: 20px 30px 50px rgb(53, 53, 53);
position: absolute;
top: 20%;
left: 30%;
display: none;
}
#divs .divs1 {
width: 300px;
height: 400px;
border: 1px solid black;
margin: 30px auto;
position: relative;
}
h3 {
text-align: center;
}
.divs1 div {
margin-top: 20px;
margin-left: 7px;
}
input {
outline: none;
}
a {
display: inline-block;
width: 80px;
height: 50px;
line-height: 50px;
background-color: thistle;
border-radius: 25px;
text-align: center;
text-decoration: none;
margin-left: 110px;
margin-top: 50px;
color: white;
}
a:hover {
background-color: steelblue;
}
p {
text-align: center;
cursor: pointer;
width: 30px;
height: 30px;
line-height: 30px;
position: absolute;
right: -200px;
top: -30px;
background-color: tomato;
font-size: 20px;
color: #fff;
display: none;
}
</style>
</head>
<body>
<button>点击我弹出对话框</button>
<div id="div"> <h1>欢迎来到注册页面</h1></div>
<div id="divs">
<div class="divs1">
<h3>用户注册界面</h3>
<div>
请输入姓名:<input type="text" style="width: 100px;" placeholder="请输入你的名字">
</div>
<p>X</p>
<div>
请输入账号:<input type="text" name="" id="" maxlength="11" placeholder="请输入十一位的账号">
</div>
<div>
请输入密码:<input type="password" name="" id="" maxlength="11" placeholder="请输入密码">
</div>
<div>
请确认密码:<input type="password" name="" id="" maxlength="11" placeholder="请确认密码">
</div>
<a href="###">提交注册</a>
</div>
</div>
<script>
var p = document.querySelector('p');
var h1 = document.querySelector('h1');
var btn = document.querySelector('button');
var div1 = document.querySelector('#div');
var div2 = document.querySelector('#divs');
btn.addEventListener('click', function () {
div1.style.backgroundColor = 'gray';
// btn.disabled = 'false';
btn.innerHTML = '不可选中';
btn.disabled = 'true';
div2.style.display = 'block';
p.style.display = 'block';
h1.style.display='block';
h1.innerHTML = '请注册';
h1.style.color = '#fff';
})
p.addEventListener('click', function () {
div2.style.display = 'none';
p.style.display = 'none';
div1.style.backgroundColor = 'aliceblue';
btn.innerHTML = '点击我弹出注册页面';
btn.disabled = '';
h1.style.display = 'none';
// h1.style.color = '#000';
})
</script>
</body>
</html>