JavaScript-模拟弹框
2021/10/16 9:39:34
本文主要是介绍JavaScript-模拟弹框,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
超级简单的模拟弹窗
<!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>
这篇关于JavaScript-模拟弹框的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-01Java部署教程:新手入门指南
- 2024-11-01Java部署教程:从入门到实践
- 2024-11-01Java订单系统教程:新手入门指南
- 2024-11-01Java分布式教程:新手入门指南
- 2024-11-01Java管理系统教程:新手入门详解
- 2024-11-01Java监控系统教程:从入门到实践
- 2024-11-01SpringCloud Alibaba入门:轻松搭建微服务架构
- 2024-11-01Swagger入门:新手必读指南
- 2024-11-01Swagger入门:轻松搭建API文档
- 2024-11-01uni-APP入门:新手快速上手指南