鱼C论坛

 找回密码
 立即注册
查看: 3028|回复: 1

[学习笔记] HTML 模态窗体演示案例

[复制链接]
发表于 2021-7-5 15:23:35 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. <!DOCTYPE html>
  2. <html>

  3. <head>
  4.     <meta charset="utf-8">
  5.     <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
  6.     <title>模态窗体演示案例</title>
  7.     <style>
  8.         #father {
  9.             background: pink;
  10.             height: 100%;
  11.             width: 100%;
  12.             position: absolute;
  13.         }
  14.         
  15.         #child {
  16.             display: none;
  17.             height: 300px;
  18.             width: 500px;
  19.             margin-top: 10%;
  20.             margin-left: 35%;
  21.             position: absolute;
  22.         }
  23.         
  24.         #son {
  25.             background: white;
  26.             height: 180px;
  27.             width: 430px;
  28.             margin-top: 60px;
  29.             margin-left: 1px;
  30.             position: absolute;
  31.         }
  32.         
  33.         #link {
  34.             display: block;
  35.             font-size: 20px;
  36.             height: 50px;
  37.             width: 50px;
  38.             border-radius: 50%;
  39.             margin-top: 30px;
  40.             margin-left: 431px;
  41.             line-height: 50px;
  42.             text-decoration: none;
  43.             background: white;
  44.             text-align: center;
  45.             position: absolute;
  46.         }
  47.         
  48.         #begin {
  49.             margin-top: 100px;
  50.             text-align: center;
  51.             display: block;
  52.         }
  53.     </style>
  54. </head>

  55. <body>
  56.     <div id="father">
  57.         <div id="begin">
  58.             <a id="begina" href="#">点击开始测试</a>
  59.         </div>
  60.         <div id="child">
  61.             <a id="link" href="#">离开</a>
  62.             <div id="son">

  63.             </div>
  64.         </div>
  65.     </div>
  66.     <script>
  67.         var sc = document.querySelector("#child")
  68.         var ba = document.querySelector("#begina")
  69.         ba.addEventListener("click", function() {
  70.             begin.style.display = 'none';
  71.             sc.style.display = "block";
  72.         })
  73.         var lk = document.querySelector("#link")
  74.         lk.addEventListener("click", function() {
  75.             begin.style.display = 'block';
  76.             sc.style.display = "none";
  77.         })
  78.     </script>
  79. </body>

  80. </html>
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2021-7-5 15:25:32 | 显示全部楼层
VSCODE  右键直接运行html文档  需加载插件:OPEN IN BROWSER
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-28 01:50

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表