将模态框案例再动手写一遍,不要全抄课堂源码,要有自己的创意

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>模态框</title>
  8. <link rel="stylesheet" href="modal1.css" />
  9. </head>
  10. <body>
  11. <header>
  12. <h2 class="title">耗子的博客</h2>
  13. <button onclick="showModal()">进入</button>
  14. </header>
  15. <div class="modal">
  16. <div class="modal-bg" onclick="closeModal()"></div>
  17. <form action="" class="modal-form">
  18. <fieldset style="display: grid; gap: 1em">
  19. <legend>欢迎</legend>
  20. <input type="email" name="email" placeholder="mouse@163.com" />
  21. <input type="password" name="password" placeholder="不少于16位" />
  22. <button>进入</button>
  23. </fieldset>
  24. </form>
  25. </div>
  26. <script src="modal.js"></script>
  27. </body>
  28. </html>

  1. /* 初始化 */
  2. * {
  3. margin: 0;
  4. padding: 0;
  5. box-sizing: border-box;
  6. }
  7. /* 头部 */
  8. header {
  9. background-color: rgb(245, 122, 7);
  10. padding: 0.5em 1em;
  11. display: flex;
  12. }
  13. /* logo */
  14. header .title {
  15. font-weight: lighter;
  16. font-style: italic;
  17. color: white;
  18. letter-spacing: 2px;
  19. text-shadow: 1px 1px 1px #555;
  20. }
  21. /* 登录按钮 */
  22. header button {
  23. margin-left: auto;
  24. width: 5em;
  25. border: none;
  26. border-radius: 0.5em;
  27. }
  28. header button:hover {
  29. cursor: pointer;
  30. background-color: rgb(41, 207, 248);
  31. color: #fff;
  32. box-shadow: 0 0 5px #fff;
  33. transition: 0.3s;
  34. }
  35. /* 模态框 */
  36. .modal .modal-form fieldset {
  37. height: 15.5em;
  38. background-color: rgb(255, 253, 224);
  39. border: none;
  40. padding: 2em 3em;
  41. box-shadow: 0 0 5px #888;
  42. }
  43. /* 模态框表单标题 */
  44. .modal .modal-form fieldset legend {
  45. padding: 7px 1.5em;
  46. background-color: rgb(218, 94, 37);
  47. color: white;
  48. }
  49. .modal .modal-form fieldset input {
  50. height: 3em;
  51. padding-left: 1em;
  52. outline: none;
  53. border: 1px solid #ddd;
  54. font-size: 14px;
  55. }
  56. /* :focus: 表单控件,获取焦点时的样式 */
  57. .modal .modal-form fieldset input:focus {
  58. box-shadow: 0 0 8px #888;
  59. border: none;
  60. }
  61. .modal .modal-form fieldset button {
  62. background-color: rgb(245, 117, 43);
  63. color: white;
  64. border: none;
  65. height: 3em;
  66. font-size: 16px;
  67. height: 2.5em;
  68. }
  69. .modal .modal-form fieldset button:hover {
  70. background-color: coral;
  71. cursor: pointer;
  72. }
  73. /* 定位 */
  74. .modal .modal-form {
  75. position: fixed;
  76. top: 10em;
  77. left: 38em;
  78. right: 38em;
  79. }
  80. /* 遮罩 */
  81. .modal .modal-bg {
  82. position: fixed;
  83. /* 坐标全部清0,请定位到四个顶点 */
  84. top: 0;
  85. left: 0;
  86. right: 0;
  87. bottom: 0;
  88. background-color: rgb(0, 0, 0, 0.5);
  89. }
  90. .modal {
  91. display: none;
  92. }

更多相关文章

  1. 简单的登陆表单、后台框架、元素样式来源与优先级
  2. 登录表单与简易框架与css元素理解
  3. 表单、内联框架及css练习
  4. 登录表单、后台架构、样式来源与优先级
  5. 表单+简单后台架构+元素样式来源与优先级
  6. 简单的登录表单
  7. 登录表单和简易后台页面
  8. 一个简单的登陆表单、后台框架及实例演示元素样式来源和优先级
  9. form表单提交、使用iframe编写后台简单布局、css样式分类与优先

随机推荐

  1. Android(安卓)MVP开发模式 google 官方Mv
  2. 开源自己写的刷票器软件(windows和Android
  3. Android应用程序开发以及背后的设计思想
  4. Android(安卓)10个快速开发框架:Afinal、T
  5. Android关于分包方案、插件化动态加载APK
  6. Android学习路线(二十七)键值对(SharedPrefe
  7. Android(安卓)资源加载与匹配
  8. android系统编译jdk版本
  9. Android(安卓)Looper
  10. 两个Android选择文件对话框