app开发定制公司HTML5+CSS3+JS制作动态背景登录界面

目录

第一步:编写

第二步:设置css样式表

第三步:编写js代码      


第一步:编写框架

1.分别新建html,css和js文档后,将css和jsapp开发定制公司分别链接至html中。

2.编写html基本框架。                                                              

                                app开发定制公司效果可参照示例图一                                                                                          

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>动态的登陆背景</title>
  6. <link rel="stylesheet" href="./css/登录界面.css">
  7. </head>
  8. <body>
  9. <div class="container">
  10. <h1>Welcome</h1>
  11. <div class="form">
  12. <input type="text" placeholder="您的账号">
  13. <input type="password" placeholder="您的密码">
  14. <button class="btn-login">登录</button>
  15. </div>
  16. </div>
  17. <ul class="bg-squares">
  18. <li></li>
  19. <li></li>
  20. <li></li>
  21. <li></li>
  22. <li></li>
  23. <li></li>
  24. <li></li>
  25. <li></li>
  26. <li></li>
  27. <li></li>
  28. </ul>
  29. </body>
  30. </html>
  31. <script src="./js/登录界面.js"></script>

示例图一

第二步:编写css样式表

1.首先设置一个渐变背景

2.将框架中的十个点变成大小不一的方块并添加动画,可参照示例图二。

  1. *{
  2. margin: 0;
  3. padding: 0;
  4. box-sizing: border-box;
  5. }
  6. body{
  7. height: 100vh;
  8. /* 弹性布局 居中显示 */
  9. display: flex;
  10. justify-content: center;
  11. align-items: center;
  12. /* 渐变背景 */
  13. background: linear-gradient(to top left,#ffe29f,#ffa99f,#ff719a);
  14. /* 溢出隐藏 */
  15. overflow: hidden;
  16. }
  17. .container{
  18. text-align: center;
  19. color: #fff;
  20. }
  21. .container h1{
  22. font-size: 40px;
  23. font-weight: 100;
  24. letter-spacing: 2px;
  25. margin-bottom: 15px;
  26. /* 过渡效果 */
  27. transition: 1s ease-in-out;
  28. }
  29. .form{
  30. display: flex;
  31. flex-direction: column;
  32. align-items: center;
  33. position: relative;
  34. z-index: 2;
  35. opacity: 1;
  36. /* 不透明度改变时的过渡效果 */
  37. transition: opacity 0.5s;
  38. }
  39. .form input{
  40. outline: none;
  41. border: 1px solid rgba(255, 255, 255, 0.4);
  42. background-color: rgba(255, 255, 255, 0.2);
  43. width: 250px;
  44. padding: 10px 15px;
  45. border-radius: 3px;
  46. margin: 0 auto 10px auto;
  47. text-align: center;
  48. color: #fff;
  49. font-size: 15px;
  50. transition: 0.25s;
  51. }
  52. .form input::placeholder{
  53. color: #fff;
  54. font-size: 14px;
  55. font-weight: 300;
  56. }
  57. .form input:hover{
  58. background-color: #fff;
  59. }
  60. .form input:focus{
  61. background-color: #fff;
  62. width: 300px;
  63. color: #ff719a;
  64. }
  65. .btn-login{
  66. outline: none;
  67. background-color: #fff;
  68. color: #ff719a;
  69. border: none;
  70. width: 250px;
  71. padding: 10px 15px;
  72. border-radius: 3px;
  73. font-size: 15px;
  74. cursor: pointer;
  75. transition: 0.25s;
  76. }
  77. .btn-login:hover{
  78. background-color: #f5f7f9;
  79. }
  80. /* 背景方块*/
  81. .bg-squares{
  82. list-style: none;
  83. position: absolute;
  84. top: 0;
  85. left: 0;
  86. width: 100%;
  87. height: 100%;
  88. z-index: 1;
  89. }
  90. .bg-squares li{
  91. width: 40px;
  92. height: 40px;
  93. background-color: rgba(255, 255, 255, 0.15);
  94. position: absolute;
  95. bottom: -160px;
  96. /* 执行动画:动画名 时长 线性 无限次播放*/
  97. animation: squres 2s linear infinite ;
  98. }
  99. /* 为每一个方块设置不同的位置、大小、动画延迟时间、动画时长、背景色 */
  100. .bg-squares li:nth-child(1){
  101. left: 10%;
  102. }
  103. .bg-squares li:nth-child(2){
  104. left: 20%;
  105. width: 80px;
  106. height: 80px;
  107. /* 动画延迟时间 */
  108. animation-delay:2s;
  109. /* 动画时长 */
  110. animation-duration: 17s;
  111. }
  112. .bg-squares li:nth-child(3){
  113. left: 25%;
  114. animation-delay: 4s;
  115. }
  116. .bg-squares li:nth-child(4){
  117. left: 40%;
  118. width: 60px;
  119. height: 60px;
  120. background-color:rgba(255, 255, 255, 0.25) ;
  121. animation-duration: 22s;
  122. }
  123. .bg-squares li:nth-child(5){
  124. left: 70%;
  125. }
  126. .bg-squares li:nth-child(6){
  127. left: 80%;
  128. width: 120px;
  129. height:120px;
  130. background-color:rgba(255, 255, 255, 0.2) ;
  131. animation-delay: 3s;
  132. }
  133. .bg-squares li:nth-child(7){
  134. left: 32%;
  135. width: 160px;
  136. height: 160px;
  137. animation-delay: 7s;
  138. }
  139. .bg-squares li:nth-child(8){
  140. left: 55%;
  141. width: 20px;
  142. height: 20px;
  143. animation-delay: 15s;
  144. animation-duration: 40s;
  145. }
  146. .bg-squares li:nth-child(9){
  147. left: 25%;
  148. width: 10px;
  149. height: 10px;
  150. background-color: rgba(255, 255, 255, 0.3);
  151. animation-delay: 2s;
  152. animation-duration: 40s;
  153. }
  154. .bg-squares li:nth-child(10){
  155. left: 90%;
  156. width: 160px;
  157. height: 160px;
  158. animation-delay: 11s;
  159. }
  160. .container.success h1{
  161. transform: translateY(75px);
  162. }
  163. .container.success .form{
  164. opacity: 0;
  165. }
  166. /*定义动画*/
  167. @keyframes squres{
  168. 0%{
  169. transform: translateY(0);
  170. }
  171. 100%{
  172. transform: translateY(-120vh) rotate(600deg);
  173. }
  174. }

 示例图二

此时如果不添加js代码,登陆键点完后没有动画;所以需要编写js代码,使画面看起来更高级。

  1. //要操作的按钮
  2. const container=document.querySelector('.container');
  3. const btn_login=document.querySelector('.btn-login');
  4. //登录按钮点击事件
  5. btn_login.addEventListener('click',function(){
  6. container.classList.add('success');
  7. })

 示例图三

 可以看到编译js代码,则可以产生这样的动画。

好了,到此就结束了。

网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发