页面效果

模态框实战

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="modal_log.css">
  9. </head>
  10. <body>
  11. <header>
  12. <h2 class="title">天空的博客</h2>
  13. <button onclick="showModal()">登录</button>
  14. </header>
  15. <!-- 模态框 -->
  16. <!-- 先写一个盒子 -->
  17. <div class="modal">
  18. <!-- 1.半透明的遮罩 -->
  19. <div class="modal-bg" onclick="closeModal()"></div>
  20. <!-- 弹层表单 -->
  21. <form action="" class="modal-form">
  22. <fieldset style="display: grid; gap: 1em">
  23. <legend>用户登录</legend>
  24. <input type="email" name="email" placeholder="user@mail.com">
  25. <input type="password" name="password" placeholder="不少于6个字符">
  26. <button>登录</button>
  27. </fieldset>
  28. </form>
  29. </div>
  30. <script src="modal.js"></script>
  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: lightseagreen;
  10. padding: 0.5em 1em;
  11. display: flex;
  12. }
  13. /* 标题 */
  14. header .title {
  15. font-weight: lighter;
  16. font-style: italic;
  17. color: white;
  18. letter-spacing: 2px;
  19. text-shadow: 1px 1px 1px #555;
  20. }
  21. /* 登录按钮 */
  22. /* 按钮的基本样式 */
  23. header button {
  24. margin-left: auto;
  25. /* margin-right: auto; */
  26. width: 5em;
  27. border: none;
  28. border-radius: 0.5em;
  29. }
  30. /* 鼠标移上去的样式 */
  31. header button:hover {
  32. cursor: pointer;
  33. background-color: coral;
  34. color: #fff;
  35. /*发光效果 box-shadow: 向右 向下 模糊半径 颜色; */
  36. box-shadow: 0 0 5px #fff;
  37. /* 过度效果,0.3秒 */
  38. transition: 0.3s;
  39. }
  40. /* 模态框 */
  41. .modal .modal-form fieldset {
  42. height: 15.5em;
  43. background-color: lightcyan;
  44. border: none;
  45. padding: 2em 3em;
  46. box-shadow: 0 0 5px #888;
  47. }
  48. /* 模态框表单标题样式 */
  49. .modal .modal-form fieldset legend {
  50. padding: 7px 1.5em;
  51. background-color: lightseagreen;
  52. color: white;
  53. }
  54. /* 输入框 */
  55. .modal .modal-form fieldset input {
  56. height: 3em;
  57. padding-left: 1em;
  58. outline: none;
  59. border: 1px solid #ddd;
  60. font-size: 14px;
  61. }
  62. /* 输入框获得焦点的样式 */
  63. .modal .modal-form fieldset input:focus {
  64. box-shadow: 0 0 8px #888;
  65. border: none;
  66. }
  67. /* 登录按钮的样式 */
  68. .modal .modal-form fieldset button {
  69. background-color: lightseagreen;
  70. color: white;
  71. border: none;
  72. height: 3em;
  73. font-size: 16px;
  74. height: 2.5em;
  75. }
  76. .modal .modal-form fieldset button:hover {
  77. background-color: coral;
  78. cursor: pointer;
  79. box-shadow: 0 0 8px #888;
  80. transition: 00.3s;
  81. }
  82. /* 定位:固定定位:fixed */
  83. .modal .modal-form {
  84. position: fixed;
  85. /* 设为定位后就收缩到最左最上了 */
  86. top: 10em;
  87. left: 38em;
  88. right: 38em;
  89. }
  90. /* 遮罩 */
  91. .modal .modal-bg {
  92. position: fixed;
  93. /* 坐标全部清零,定位到四个顶点*/
  94. top: 0em;
  95. left: 0;
  96. right: 0;
  97. bottom: 0;
  98. background-color: rgb(0, 0, 0, 0.5);
  99. /* 半透明 */
  100. }
  101. .modal {
  102. display: none;
  103. }

更多相关文章

  1. android RadioButton放大或者缩小
  2. Android(安卓)在百度地图上显示自己的实时位置
  3. 练习PHP中文网首页
  4. 模态框案例
  5. 推荐一个好看Table表格的css样式代码详解
  6. html加css样式实现js美食项目首页示例代码
  7. Android日历(Calendar,dataPicker)
  8. EditText 行间距 以及光标高度和样式
  9. Android百度地图调用和GPS定位

随机推荐

  1. android gesture检测
  2. Phonegap软键盘遮挡输入框问题
  3. 漫谈Android安全框架
  4. Android开发者指南(11) ―― Optimizing
  5. Android NDK环境搭建
  6. Android(安卓)Lifecycle 生命周期管理
  7. HelloWorld-----Google手机操作系统Andro
  8. android客户端与服务端交互的三种方式
  9. android browser 的几个小feature (一)
  10. Android(安卓)地区语言和简写对照表