博主信息
博文 15
粉丝 0
评论 0
访问量 9513
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
模态框练习
啊℃。㏄
原创
506人浏览过

模态框界面

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. }

效果如下:

批改老师:PHPzPHPz

批改状态:合格

老师批语:
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学