博主信息
博文 9
粉丝 0
评论 0
访问量 6319
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
模态框初识
恒儿哥哥
原创
614人浏览过

模态框学习

  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="model.css">
  9. <script src="model.js"></script>
  10. </head>
  11. <body>
  12. <header>
  13. <h2 class="title">blog</h2>
  14. <figure>
  15. <div>
  16. <span>Hover Me</span>
  17. <span onclick="showModal()">登录</span>
  18. </div>
  19. </figure>
  20. </header>
  21. <div class="jpg">
  22. <!-- 内容区 -->
  23. </div>
  24. <!-- 模态框 -->
  25. <div class="modal">
  26. <!-- 半透明遮罩 -->
  27. <div class="modal-bg" onclick="closeModal()"></div>
  28. <!-- 弹层表单 -->
  29. <form action="" class="modal-form">
  30. <fieldset style="display: grid; gap: 1em;">
  31. <legend>用户登录</legend>
  32. <input type="email" name="emali" placeholder="user@mail.com"/>
  33. <input type="password" name="psw" id="psw" placeholder="密码">
  34. <button>登录</button>
  35. </fieldset>
  36. </form>
  37. </div>
  38. </body>
  39. </html>

css

  1. /* 初始化 */
  2. * {
  3. margin: 0;
  4. padding: 0;
  5. box-sizing: border-box;
  6. }
  7. /* 头部样式 */
  8. header {
  9. background-color: #2C3E50;
  10. padding: 0.5em 1em;
  11. display: flex;
  12. height: 10vh;
  13. }
  14. header .title {
  15. font-weight:400;
  16. font-style:normal;
  17. font-size: 35pt;
  18. color: aliceblue;
  19. letter-spacing: 10px;
  20. text-shadow: 1px 1px 1px #D0D0D0;
  21. }
  22. /* text-shadow:(水平阴影(必须),垂直阴影(必须),模糊距离(可选),阴影颜色(必须)) */
  23. /* letter-spacing:(字间距) */
  24. @import url("https://fonts.googleapis.com/css?family=Source+Sans+Pro");
  25. figure {
  26. width: 200px;
  27. height: 60px;
  28. cursor: pointer;
  29. perspective: 500px;
  30. -webkit-perspective: 500px;
  31. margin-left: auto;
  32. margin-top: 10px;
  33. }
  34. figure div {
  35. height: 100%;
  36. transform-style: preserve-3d;
  37. -webkit-transform-style: preserve-3d;
  38. transition: 0.25s;
  39. -webkit-transition: 0.25s;
  40. }
  41. figure:hover div {
  42. transform: rotateX(-90deg);
  43. }
  44. span {
  45. width: 100%;
  46. height: 100%;
  47. position: absolute;
  48. box-sizing: border-box;
  49. border: 5px solid #fff;
  50. font-family: "Source Sans Pro", sans-serif;
  51. line-height: 50px;
  52. font-size: 17pt;
  53. text-align: center;
  54. text-transform: uppercase;
  55. }
  56. span:nth-child(1) {
  57. color: #fff;
  58. transform: translate3d(0, 0, 30px);
  59. -webkit-transform: translate3d(0, 0, 30px);
  60. }
  61. span:nth-child(2) {
  62. color: #1c175d;
  63. background: #fff;
  64. transform: rotateX(90deg) translate3d(0, 0, 30px);
  65. -webkit-transform: rotateX(90deg) translate3d(0, 0, 30px);
  66. }
  67. /* 模态框 */
  68. .modal .modal-form{
  69. width: 20em;
  70. height: 20em;
  71. }
  72. .modal .modal-form fieldset{
  73. height: 15.5em;
  74. width: 20em;
  75. background-color: #d0d0d0;
  76. border:none;
  77. padding: 2rem,3em;
  78. box-shadow: 0 0 5px #888;
  79. border-radius: 0 0 1em 1em ;
  80. }
  81. /* 模态框表单标题 */
  82. .modal .modal-form fieldset legend{
  83. padding:5px 1.5em;
  84. height: 3em;
  85. width: 25em;
  86. background-color: #2C3E50;
  87. color: white;
  88. text-align: center;
  89. border-radius: 1em 1em 0 0;
  90. }
  91. /* 表单 */
  92. .modal .modal-form fieldset input{
  93. height: 3em;
  94. width: 25em;
  95. padding: 0.6em;
  96. outline: none;
  97. border:1px solid #2C3E50;
  98. font-size: 14px;
  99. margin: 0.6em auto;
  100. }
  101. .modal .modal-form fieldset button{
  102. width: 10em;
  103. text-align: center;
  104. position: relative;
  105. left: 7.5em;
  106. bottom: 0.6em;
  107. }
  108. /* focus */
  109. .modal .modal-form fieldset input :focus{
  110. box-shadow: 0 0 8px #888;
  111. border:none;
  112. }
  113. .modal .modal-form fieldset button{
  114. background-color: #2C3E50;
  115. color: white;
  116. border:none;
  117. font-size: 16px;
  118. height: 2.5em;
  119. }
  120. .modal .modal-form fieldset button:hover{
  121. cursor: pointer;
  122. background-color:black;
  123. transition: 0.3s;
  124. box-shadow: 4px 4px 1px white;
  125. }
  126. /* 定位 */
  127. .modal .modal-form{
  128. position:fixed;
  129. top:20em;
  130. left: auto;
  131. right: 50em;
  132. }
  133. .modal .modal-form fieldset legend {
  134. position: relative;
  135. bottom: 1.01em;
  136. }
  137. /* 遮罩 */
  138. .modal .modal-bg{
  139. position: fixed;
  140. top:0;
  141. left: 0;
  142. right: 0;
  143. bottom: 0;
  144. /* 定位在四个方向的原点 */
  145. background-color: rgb(0,0,0,0.5);
  146. }
  147. .modal {
  148. display: none;
  149. }
  150. .jpg {
  151. width: 100vw;
  152. height: 100vh;
  153. background-color: #D0D0D0;
  154. }
批改老师: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+教程免费学