Blogger Information
Blog 8
fans 0
comment 0
visits 3603
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
模态框案例
平凡之路
Original
403 people have browsed it

MTML

  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="stylesheet" href="/HTML/css/modal.css" />
  9. </head>
  10. <body>
  11. <header>
  12. <h2 class="title">晖创财务</h2>
  13. <button onelick="showmodal()">登录</button>
  14. </header>
  15. <!-- 模态框 -->
  16. <div class="modal">
  17. <!-- 1半透明遮罩 -->
  18. <div class="modal-bg" onclick="cloaemodal()"></div>
  19. <!-- 2弹层表单 -->
  20. <form action="" class="modal-form">
  21. <fieldset style="display: grid; gap: 1em">
  22. <legend>
  23. <button>账号登录</button>
  24. <button>短息登录</button>
  25. </legend>
  26. <input type="admin" name="name" id="" placeholder="账号" />
  27. <input type="user" name="usser" id="" placeholder="密码(8位数以上)" />
  28. <button class="box1">登录</button>
  29. </fieldset>
  30. </form>
  31. </div>
  32. </body>
  33. </html>

CSS

  1. /* 初始化 */
  2. * {
  3. margin: 0;
  4. padding: 0;
  5. box-sizing: border-box;
  6. }
  7. /* 头部样式 */
  8. header {
  9. background-color: cornflowerblue;
  10. padding: 0.5em 1em;
  11. display: flex;
  12. }
  13. /* logo */
  14. header .title {
  15. color: white;
  16. letter-spacing: 5px;
  17. text-shadow: 1px 1px 1px #555;
  18. }
  19. /* 登录按钮 */
  20. header button {
  21. margin-left: auto;
  22. width: 5em;
  23. border: none;
  24. border-radius: 0.5em;
  25. }
  26. header button:hover {
  27. cursor: pointer;
  28. background-color: pink;
  29. color: #fff;
  30. box-shadow: 0 0 5px #fff;
  31. transition: 0.3s;
  32. }
  33. /* 模态框 */
  34. .modal .modal-form fieldset {
  35. height: 15.5em;
  36. background-color: lightcyan;
  37. border: none;
  38. padding: 2em 3em;
  39. box-shadow: 0 0 0 5px lavender;
  40. }
  41. /* 模态框表单标题 */
  42. .modal .modal-form fieldset legend {
  43. padding: 0px 0px;
  44. width: 300px;
  45. box-shadow: 0 0 0 0px cornflowerblue;
  46. background-color: cornflowerblue;
  47. }
  48. /* 定位 */
  49. .modal .modal-form {
  50. position: fixed;
  51. top: 10em;
  52. left: 30em;
  53. right: 30em;
  54. }
  55. /* 遮罩 固定定位 */
  56. .modal .modal-bg {
  57. position: fixed;
  58. top: 0;
  59. left: 0;
  60. right: 0;
  61. bottom: 0;
  62. background-color: rgba(0, 0, 0, 0.281);
  63. }
  64. div button:hover {
  65. background-color: coral;
  66. color: #fff;
  67. box-shadow: 0 0 5px #fff;
  68. font-size: ;
  69. transition: 0.1s;
  70. }
  71. legend button {
  72. padding: 4px 4px;
  73. width: 148px;
  74. font size: 14px;
  75. }
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!