定制小程序开发基于 HTML5/CSS3 制作漂亮的登录页面

HTML5 是对 HTML 定制小程序开发标准的第五次修订。定制小程序开发其主要的目标是将互联网语义化,定制小程序开发以便更好地被人类和机器阅读,定制小程序开发并同时提供更好地支持定制小程序开发各种媒体的嵌入。HTML5是互联网的下一代标准,被认为是互联网的核心技术之一。CSS3是CSS(层叠样式表)技术的升级版本,CSS3原CSS基础上新增了很多新特征。

此项目基于 HTML5/CSS3 制作漂亮的登录页面,教学目标:

  • CSS3 设置背景图像
  • CSS3 圆角/透明效果实现
  • CSS 属性选择器/伪类选择器
  • CSS3 过滤效果语法使用

第一步:编写登录静态默认页面布局

利用标签,实现登录静态默认页面布局。

目录结构:

pretty-login/        --根目录
  ├── css/            --css文件目录
  └── images/         --图片文件目录  
  index.html          --入口html文件

免费的图片库资源:

index.html

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>shixun.online</title>
  8. <!-- 引入外部CSS文件 -->
  9. <link rel="stylesheet" href="css/style.css">
  10. </head>
  11. <body>
  12. </body>
  13. </html>

style.css

  1. body {
  2. margin: 0;
  3. padding: 0;
  4. background-image: url(../images/bg.jpg);
  5. background-repeat: no-repeat;
  6. background-size: cover;
  7. }

第二步:编写登录页面主窗口

index.html 

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>shixun.online</title>
  8. <!-- 引入外部CSS文件 -->
  9. <link rel="stylesheet" href="css/style.css">
  10. </head>
  11. <body>
  12. <form class="login-form" action="#" method="POST">
  13. <h1>实训在线-登录</h1>
  14. </form>
  15. </body>
  16. </html>

style.css

  1. .container {
  2. width: 300px;
  3. height: 400px;
  4. /* 水平居中 */
  5. margin: 150px auto;
  6. padding: 20px;
  7. /* border: 1px solid #000000; */
  8. position: relative;
  9. }
  10. .container h2 {
  11. text-align: center;
  12. font-size: 20px;
  13. color: #478fb7;
  14. }
  15. .container img {
  16. width: 120px;
  17. height: 95px;
  18. /* 绝对定位 */
  19. position: absolute;
  20. top: -20%;
  21. left: 50%;
  22. /* 将指定元素向左移动其自身宽度的 50% ,实现将其水平居中*/
  23. transform: translate(-50%, 0);
  24. }
  25. .container input {
  26. width: 100%;
  27. padding: 10px 15px;
  28. border: 1px solid #dddddd;
  29. /* 添加圆角效果 */
  30. border-radius: 50px;
  31. margin-bottom: 20px;
  32. /* 去掉外边框 */
  33. outline: none;
  34. font-size: 14px;
  35. /* CSS3 提供的属性,设置元素的宽度包含其 padding 和 border 的宽度 */
  36. box-sizing: border-box;
  37. }
  38. /* > 表示设置当前元素下的直接子元素(儿子元素) */
  39. .username>img {
  40. /* 隐藏元素 */
  41. display: none;
  42. width: 120px;
  43. height: 113px;
  44. }
  45. /* :focus 当前元素获得焦点 */
  46. /* :focus-within 当前元素或其子元素获得焦点 */
  47. .username:focus-within>img {
  48. display: block;
  49. }
  50. .username:focus-within>input {
  51. /* 修改输入框的边框颜色 */
  52. border-color: #f29855;
  53. }
  54. /* ~表示定位当前元素后的所有兄弟元素 */
  55. /* 当前 class=username 的元素或其子元素获得焦点时,隐藏其后的同级兄弟 img 元素 */
  56. .username:focus-within~img {
  57. display: none;
  58. }

 第三步:编写“用户名”&“密码”输入框

index.html 

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>shixun.online</title>
  8. <!-- 引入外部CSS文件 -->
  9. <link rel="stylesheet" href="css/style.css">
  10. </head>
  11. <body>
  12. <form class="login-form" action="#" method="POST">
  13. <h1>实训在线-登录</h1>
  14. <input type="text" name="name" placeholder="用户名...">
  15. <input type="password" name="password" placeholder="密码...">
  16. </form>
  17. </body>
  18. </html>

style.css

  1. body {
  2. margin: 0;
  3. padding: 0;
  4. background-image: url(../images/bg.jpg);
  5. background-repeat: no-repeat;
  6. background-size: cover;
  7. }
  8. .login-form {
  9. width: 300px;
  10. background: #191919;
  11. padding: 30px;
  12. /* 水平居中处理 */
  13. margin: 10% auto 0 auto;
  14. /* 圆角效果 */
  15. border-radius: 30px;
  16. opacity: 0.6;
  17. text-align: center;
  18. }
  19. .login-form h1 {
  20. color: white;
  21. font-weight: 500;
  22. }
  23. .login-form input[type="text"], .login-form input[type="password"] {
  24. background: none;
  25. width: 200px;
  26. border: 2px solid #3498db;
  27. border-radius: 25px;
  28. font-size: 16px;
  29. margin: 10px auto;
  30. padding: 14px 10px;
  31. text-align: center;
  32. outline: none;
  33. color: white;
  34. /* CSS3 过渡效果,设置时长 */
  35. transition: 0.25s;
  36. }
  37. .login-form input[type="text"]:focus, .login-form input[type="password"]:focus {
  38. width: 280px;
  39. border-color: #2ecc71;
  40. }

第四步:编写“登录”&“重置”按钮

index.html

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>shixun.online</title>
  8. <!-- 引入外部CSS文件 -->
  9. <link rel="stylesheet" href="css/style.css">
  10. </head>
  11. <body>
  12. <form class="login-form" action="#" method="POST">
  13. <h1>实训在线-登录</h1>
  14. <input type="text" name="name" placeholder="用户名...">
  15. <input type="password" name="password" placeholder="密码...">
  16. <input type="submit" value="登 录">
  17. <input type="reset" value="重 置">
  18. </form>
  19. </body>
  20. </html>

style.css (同上)

项目总结,通过此项目的学习了解以下知识点内容:

  • 掌握如何利用 CSS3 设置背景图片:background-image: url(../img/bg.jpg)
  • 掌握如何利用 CSS3 设置元素的透明效果:opacity: 0.6;
  • 掌握如何利用 CSS3 设置圆角效果:border-radius: 25px;
  • 掌握如何利用 CSS3 实现过渡效果:transition: 0.25s;
  • 掌握 CSS 中属性选择器和伪类选择器的使用方法
网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发