" />

飞道的博客

前端——好看的登录页面(二)

448人阅读  评论(0)

 

UserLogin.html


   
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>用户登录界面 </title>
  6. <link rel="stylesheet" href="styleLogin.css"/>
  7. </head>
  8. <body>
  9. <div class="container">
  10. <div class="panel">
  11. <div class="content">
  12. <div class="switch">
  13. <h1 id="login">登录 </h1>
  14. </div>
  15. <form action="">
  16. <div id="userName" class="input" aria-placeholder="用户名"> <input type="text"> </div>
  17. <div id="password" class="input" aria-placeholder="密码"> <input type="password"> </div>
  18. <p>
  19. <a id="signUp" href="UserSignUp.html" class="input">跳转注册 </a>
  20. <span>| </span>
  21. <a id="forget" href="UserRetrieve.html" class="input">忘记密码? </a>
  22. </p>
  23. <button class="button">登录 </button>
  24. </form>
  25. </div>
  26. </div>
  27. </div>
  28. </body>
  29. <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.slim.js"> </script>
  30. <script>
  31. $( '.input input').on( 'focus', function () {
  32. $( this).parent().addClass( 'focus');
  33. })
  34. $( '.input input').on( 'blur', function () {
  35. if($( this).val() === '')
  36. $( this).parent().removeClass( 'focus');
  37. })
  38. </script>
  39. </html>

styleLogin.css


   
  1. * {
  2. margin: 0;
  3. padding: 0;
  4. }
  5. body {
  6. height: 100vh;
  7. display: flex;
  8. align-items: center;
  9. justify-content: center;
  10. background: url( "星空.jpg") no-repeat;
  11. }
  12. .container {
  13. position: relative;
  14. width: 24rem;
  15. }
  16. .panel {
  17. position: absolute;
  18. top: 50%;
  19. left: 50%;
  20. transform: translate(-50%,-50%);
  21. background: rgba(0,0,0,.8);
  22. display: flex;
  23. justify-content: center;
  24. width: 400px;
  25. padding: 40px;
  26. box-sizing: border-box;
  27. box-shadow: 0 15px 25px rgba(0,0,0,.5);
  28. border-radius: 10px;
  29. }
  30. .switch h1 {
  31. text-align: center;
  32. font-size: 1.4rem;
  33. color: rgba(125, 116, 255,.8);
  34. border-bottom: rgba(125, 116, 255,.8) solid 2px;
  35. cursor: default;
  36. }
  37. .input input {
  38. outline: none;
  39. width: 100%;
  40. border: none;
  41. background: none;
  42. border-bottom: . 1rem solid #7d74ff;
  43. color: rgba(37, 215, 202, 0.84);
  44. font-size: 1rem;
  45. }
  46. .input ::after {
  47. content: attr(aria-placeholder);
  48. position: absolute;
  49. left: 0;
  50. top: - 20%;
  51. font-size: 1.1rem;
  52. color: rgba(125, 116, 255, 0.44);
  53. transition: . 3s;
  54. }
  55. .input .focus ::after {
  56. top: - 70%;
  57. font-size: 1rem;
  58. }
  59. .input #forget {
  60. color: #7d74ff;
  61. font-size: 0.8rem;
  62. text-decoration: none;
  63. }
  64. .input #forget :hover {
  65. color: rgba(138, 143, 255, 0.4);
  66. }
  67. .input #signUp {
  68. color: #7d74ff;
  69. font-size: 0.8rem;
  70. text-decoration: none;
  71. }
  72. .input #signUp :hover {
  73. color: rgba(138, 143, 255, 0.4);
  74. }
  75. form p {
  76. text-align: center;
  77. }
  78. form span {
  79. color: #7d74ff;
  80. font-size: 0.8rem;
  81. cursor: default;
  82. }
  83. form {
  84. width: 12rem;
  85. margin: 1rem 0 0;
  86. }
  87. form .input {
  88. position: relative;
  89. opacity: 1;
  90. width: 100%;
  91. margin: 2rem 0 0;
  92. height: 42px;
  93. }
  94. form .input #userName {
  95. margin: 3rem 0 0;
  96. }
  97. form .input #password {
  98. height: 1.6rem;
  99. }
  100. form button {
  101. display: block;
  102. border: none;
  103. outline: none;
  104. margin: 2rem 61px 0;
  105. width: 56px;
  106. height: 56px;
  107. border-radius: 50%;
  108. background: linear-gradient(90deg, #8a8fff, rgb(216, 174, 255));
  109. box-shadow: 0 0 8px #8a8fff;
  110. cursor: pointer;
  111. }
  112. form button :hover {
  113. border: none;
  114. outline: none;
  115. margin: 2rem - 7px 0;
  116. width: 100%;
  117. height: 3.5rem;
  118. border-radius: 3rem;
  119. background: linear-gradient(90deg, rgba(138, 143, 255, 0.75), rgba(216, 174, 255, 0.75));
  120. box-shadow: 0 0 8px #8a8fff;
  121. cursor: pointer;
  122. color: rgba(0,0,0,0.6);
  123. transition: . 4s;
  124. }

 

参考:

https://www.bilibili.com/video/av61650993?t=42


转载:https://blog.csdn.net/hxxjxw/article/details/104926755
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场