代码

html

  1. <body>
  2. <header>
  3. <h1 class="title">千千的博客</h1>
  4. <button onclick="showModal()">登录</button>
  5. </header>
  6. <!-- 模态框 -->
  7. <div class="modal">
  8. <!-- 1.半透明的遮罩 -->
  9. <div class="modal-bg" onclick="closeModal()"></div>
  10. <form action="" class="modal-form">
  11. <fieldset style="display: grid; gap: 1em">
  12. <legend>用户登录</legend>
  13. <input type="email" name="email" placeholder="user@email.com" />
  14. <input type="password" name="password" placeholder="不少于6位" />
  15. <button>登录</button>
  16. </fieldset>
  17. </form>
  18. </div>
  19. <script src="modal.js"></script>
  20. </body>

css样式

<link rel="stylesheet" href="modaltext.css">

  1. /* 初始化 */
  2. *{
  3. margin: 0;
  4. padding: 0;
  5. box-sizing: border-box;
  6. }
  7. /* 头部 */
  8. header{
  9. background-color: coral;
  10. padding: 2em 5em;
  11. display: flex;
  12. }
  13. /* logo */
  14. header .title{
  15. font-weight:lighter;
  16. font-style:italic;
  17. color:grey;
  18. letter-spacing:50px;
  19. text-shadow: 1px 1px 1px white
  20. }
  21. /* 登录按钮 */
  22. header button{
  23. margin-left: auto;
  24. margin-top: auto;
  25. width: 6em;
  26. height: 2em;
  27. border: none;
  28. border-radius:0.5em;
  29. }
  30. header button:hover{
  31. cursor: pointer;
  32. background-color: coral;
  33. color: white;
  34. box-shadow: 0 0 10px #fff;
  35. transition: 0.5s;
  36. }
  37. /* 模态框 */
  38. .modal .modal-form fieldset {
  39. height:15.5em;
  40. background-color: lightsalmon;
  41. border: none;
  42. padding: 2em 3em;
  43. box-shadow:0 0 10px #888;
  44. }
  45. /* 模态框表单标题 */
  46. .modal .modal-form fieldset legend {
  47. padding:7px 1.5em;
  48. color: #fff;
  49. border:solid white 0.5px;
  50. background-color: orange;
  51. }
  52. .modal .modal-form fieldset input {
  53. height:3em;
  54. padding-left:1em;
  55. border: 1px solid #DDD;
  56. outling:none;
  57. font-size: 14px;
  58. }
  59. /* :focus: 表单控件,获取焦点时的样式 */
  60. .modal .modal-form fieldset input:focus {
  61. box-shadow:0 0 10px rgb(90, 90, 90);
  62. border:none;
  63. }
  64. .modal .modal-form fieldset button{
  65. background-color: orange;
  66. color:white;
  67. border:none;
  68. height:3em;
  69. font-size:16px;
  70. height:2.5em;
  71. box-shadow:0 0 10px white;
  72. }
  73. .modal .modal-form fieldset button:hover{
  74. background-color:coral;
  75. /* cursor: 网页浏览时用户鼠标指针的样式或图形形状。pointer:光标为一只手 */
  76. cursor:pointer;
  77. }
  78. /* 定位 */
  79. .modal .modal-form {
  80. position:fixed;
  81. top:10em;
  82. left:35em;
  83. right:35em;
  84. }
  85. /* 遮罩 */
  86. .modal .modal-bg {
  87. position: fixed;
  88. /* 坐标全部清零,定位到四个顶点 */
  89. top: 0;
  90. left: 0;
  91. right: 0;
  92. bottom: 0;
  93. background-color: rgb(0,0,0,0.5);
  94. }
  95. .modal{
  96. display:none;
  97. }

效果


更多相关文章

  1. Android(安卓)实现不同样式风格的CharSequence
  2. 自定义progressbar 样式
  3. Android(安卓)listview 制作表格样式+由下往上动画弹出效果实现
  4. Android(安卓)自定义RadioButton的样式
  5. fastadmin cas登录404错误
  6. android自定义按钮控件样式
  7. android 控制按钮各个状态的样式
  8. Android(安卓)拖动条SeekBar的简单使用
  9. Android登录记住密码,AES加密保存密码

随机推荐

  1. edittext底部输入
  2. android Installation error: INSTALL_FA
  3. android学习之textView布局文件
  4. Android Studio中找到apk
  5. android N0 屏蔽某个应用的通知
  6. Android 总结1
  7. 安卓开发问题记录
  8. ListView CheckBox点击事件
  9. android app content
  10. android 分段显示文本颜色控件