Blogger Information
Blog 6
fans 0
comment 0
visits 2612
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
模态框案例
P粉150142745
Original
484 people have browsed it

模态框案例

  1. <!DOCTYPE html>
  2. <html lang="en">
  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="styleheet" href="modal.css" />
  9. </head>
  10. <body>
  11. <header>
  12. <h2 class="title">myblogs</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="user@email.com" />
  21. <input type="password" name="password" placeholder="不少于6位" />
  22. <button>登录</button>
  23. </fieldset>
  24. </form>
  25. </div>
  26. <script src="modal.js"></script>
  27. </body>
  28. <style>
  29. * {
  30. margin: 0;
  31. padding: 0;
  32. box-sizing: border-box;
  33. }
  34. header {
  35. background-color: lightseagreen;
  36. padding: 0.8em 1em;
  37. display: flex;
  38. }
  39. header .title {
  40. font-weight: lighter;
  41. font-style: italic;
  42. color: white;
  43. letter-spacing: 2px;
  44. text-shadow: 1px 1px 1px rgb(133, 132, 132);
  45. }
  46. header button {
  47. margin-left: auto;
  48. width: 5em;
  49. border: none;
  50. border-radius: 0.6em;
  51. }
  52. header button:hover {
  53. cursor: pointer;
  54. background-color: rgb(149, 149, 98);
  55. color: #fff;
  56. box-shadow: 0 0 5px #fff;
  57. transition: 0.4s;
  58. }
  59. /* 模态框*/
  60. .modal .modal-form fieldset {
  61. height: 15.5em;
  62. background-color: lightcyan;
  63. border: none;
  64. padding: 2em 3em;
  65. box-shadow: 0 0 5px #888;
  66. }
  67. /* 模态框表单标题 */
  68. .modal .modal-form fieldset legend {
  69. padding: 7px 1.5em;
  70. background-color: rgb(7, 126, 120);
  71. color: white;
  72. }
  73. .modal .modal-form fieldset input {
  74. height: 3em;
  75. padding-left: 1em;
  76. outline: none;
  77. border: 1px solid rgb(114, 13, 13);
  78. font-size: 14px;
  79. }
  80. /* :focus: 表单控件,获取焦点时的样式 */
  81. .modal .modal-form fieldset input:focus {
  82. box-shadow: 0 0 8px #888;
  83. border: none;
  84. }
  85. .modal .modal-form fieldset button {
  86. background-color: lightseagreen;
  87. color: white;
  88. border: none;
  89. height: 3em;
  90. font-size: 16px;
  91. height: 2.5em;
  92. border-radius: 0.6em;
  93. }
  94. .modal .modal-form fieldset button:hover {
  95. background-color: rgb(221, 173, 15);
  96. cursor: pointer;
  97. }
  98. /* 定位 */
  99. .modal .modal-form {
  100. position: fixed;
  101. top: 10em;
  102. left: 18em;
  103. right: 38em;
  104. }
  105. /* 遮罩 */
  106. .modal .modal-bg {
  107. position: fixed;
  108. /* 坐标全部清0,请定位到四个顶点 */
  109. top: 0;
  110. left: 0;
  111. right: 0;
  112. bottom: 0;
  113. background-color: rgba(185, 48, 48, 0.4);
  114. }
  115. .modal {
  116. display: none;
  117. }
  118. </style>
  119. </html>

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post