Blogger Information
Blog 15
fans 0
comment 0
visits 6301
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
模态框练习
啊℃。㏄
Original
343 people have browsed it

模态框界面

html:

  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="作业1.css">
  9. </head>
  10. <body>
  11. <header>
  12. <h2>后台管理系统</h2>
  13. <button>登录</button>
  14. </header>
  15. <!-- 模态框 -->
  16. <div class="modal">
  17. <!-- 半透明的遮罩 -->
  18. <div class="modal-bg"></div>
  19. <!-- 弹窗表单 -->
  20. <form action="" class="my_form">
  21. <fieldset style="display: grid;gap: 1em;">
  22. <legend>用户登录</legend>
  23. <label for="user">账号:</label>
  24. <input type="text" id="user" placeholder="请输入账号">
  25. <label for="pwd">密码:</label>
  26. <input type="password" id="pwd" placeholder="至少8位">
  27. <button>登录</button>
  28. </fieldset>
  29. </form>
  30. </div>
  31. </body>
  32. </html>

css:

  1. /* 初始化 */
  2. * {
  3. margin: 0;
  4. padding: 0;
  5. box-sizing: border-box;
  6. }
  7. /* 头部 */
  8. header {
  9. background-color:chocolate;
  10. padding: 1.5em 1em;
  11. display: flex;
  12. }
  13. /* logo */
  14. header > h2 {
  15. margin-left: auto ;
  16. margin-right: auto;
  17. color:azure;
  18. }
  19. /* 登录按钮 */
  20. header > button {
  21. letter-spacing: 2px;
  22. border: none;
  23. border-radius: 0.5em;
  24. width: 5em;
  25. }
  26. header >button:hover {
  27. cursor: pointer;
  28. background-color:blueviolet;
  29. color: white;
  30. transition: 0.5s;
  31. box-shadow: 0 0 10px white;
  32. }
  33. /* 模态框 */
  34. .modal .my_form fieldset {
  35. height: 18em;
  36. border: none;
  37. padding: 3em 7em;
  38. background-color:gainsboro;
  39. }
  40. /* 模态框表单内容 */
  41. .modal .my_form fieldset input {
  42. height: 25px;
  43. outline: none;
  44. margin-left: 1em;
  45. border: 1px solid white;
  46. }
  47. /* 获取焦点后,阴影发光 */
  48. .modal .my_form fieldset input:focus {
  49. box-shadow: 0 0 10px black;
  50. }
  51. /* 表单登录按钮 */
  52. .modal .my_form fieldset button {
  53. cursor: pointer;
  54. font-size: 15px;
  55. letter-spacing: 3px;
  56. border-radius: 1.5em;
  57. }
  58. /* 登录键鼠标悬停 */
  59. .modal .my_form fieldset button:hover {
  60. background-color:blueviolet;
  61. color: white;
  62. outline: none;
  63. border-radius: 1.5em;
  64. transition: 0.5s;
  65. border: 1px solid ;
  66. box-shadow: 0 0 10px white;
  67. }
  68. /* 定位 */
  69. .modal .my_form {
  70. position: fixed;
  71. top: 15em;
  72. left: 35em;
  73. right:40em;
  74. }
  75. /* 遮罩半透明 */
  76. .modal .modal-bg {
  77. position: fixed;
  78. top: 0;
  79. left: 0;
  80. right: 0;
  81. bottom: 0;
  82. background-color:rgb(0,0,0,0.5 );
  83. }

效果如下:

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