Blogger Information
Blog 13
fans 0
comment 0
visits 10460
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
一个简单的模态框
微光
Original
695 people have browsed it

1、效果展示

2、html代码

  1. <body>
  2. <!-- 页眉 -->
  3. <header>
  4. <div class="logo">
  5. <a href="">PHP中文网</a>
  6. </div>
  7. <div class="logo">
  8. <a href="">登陆</a>
  9. </div>
  10. </header>
  11. <!-- 模态框 -->
  12. <div class="container">
  13. <!-- 蒙版 -->
  14. <div class="moban"></div>
  15. <!-- 用户表单 -->
  16. <div class="biaodan">
  17. <h3>用户登录</h3>
  18. <button>关闭</button>
  19. <form action="">
  20. <label for="username">用户名:</label>
  21. <input type="text" id="username" name="username" />
  22. <label for="passwd">密码:</label>
  23. <input type="text" id="passwd" name="passwd" />
  24. <label for="xueli">学历:</label>
  25. <select name="xueli" id="xueli">
  26. <option value="1">高中</option>
  27. <option value="2" selected>大专</option>
  28. <option value="3">本科</option>
  29. <option value="4">硕士</option>
  30. <option value="5">博士</option>
  31. </select>
  32. <button>登陆</button>
  33. </form>
  34. </div>
  35. </div>
  36. </body>

3、css代码

  1. <style>
  2. * {
  3. margin: 0;
  4. padding: 0;
  5. box-sizing: border-box;
  6. }
  7. a {
  8. text-decoration: none;
  9. color: #ffffff;
  10. }
  11. /* 导航 */
  12. header {
  13. width: 100vw;
  14. height: 3em;
  15. padding: 1.5em;
  16. font-size: 1.2rem;
  17. background: linear-gradient(to right, cornflowerblue 50%, green 90%);
  18. display: flex;
  19. justify-content: space-between;
  20. align-items: center;
  21. }
  22. /* 模态框 */
  23. .moban {
  24. position: fixed;
  25. top: 0;
  26. left: 0;
  27. right: 0;
  28. bottom: 0;
  29. background-color: #000000;
  30. opacity: 0.5;
  31. }
  32. .biaodan {
  33. min-width: 20em;
  34. background: cornflowerblue;
  35. padding: 1em;
  36. border-radius: 5%;
  37. position: fixed;
  38. top: 10em;
  39. left: 35%;
  40. right: 35%;
  41. }
  42. .biaodan > form {
  43. display: grid;
  44. grid-template-columns: 4em 1fr;
  45. gap: 1em;
  46. padding: 1.2em;
  47. }
  48. .biaodan > form > button {
  49. grid-column: span 2;
  50. height: 3em;
  51. border-radius: 1em;
  52. }
  53. .biaodan > button {
  54. position: absolute;
  55. top: 1.3em;
  56. right: 2em;
  57. }
  58. .container {
  59. /* display: none; */
  60. }
  61. </style>
Correcting teacher:灭绝师太灭绝师太

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
1 comments
灭绝师太 2020-11-27 15:22:05
页面做的炫酷, 不用php做前后端交互,可惜了了.
1 floor
Author's latest blog post