经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » HTML/CSS » CSS » 查看文章
使用css样式设计一个简单的html登陆界面的实现_CSS教程_CSS
来源:jb51  时间:2021/4/6 9:28:04  对本文有异议

login.html部分:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. <!--引入字体图标库-->
  7. <link rel="stylesheet" type="text/css" href="font-awesome-4.7.0/css/font-awesome.min.css">
  8. <link rel="stylesheet" href="css/reset.css">
  9. <link rel="stylesheet" href="css/login.css">
  10. </head>
  11. <body>
  12.  
  13. <div class="wrap">
  14. <h1>易购商城后台管理系统</h1>
  15. <form action="">
  16. <div class="input-group">
  17. //输入框左边的类似图标的东西是一种字体
  18. //可在网上下载文件font-awesome-4.7.0后直接粘贴在项目目录下使用
  19. <i class="icon-user fa fa-user"></i>
  20. <input type="text" name="" class="form-control" placeholder="请输入用户名">
  21. </div>
  22. <div class="input-group">
  23. <i class="icon-user fa fa-lock"></i>
  24. <input type="password" name="" class="form-control" placeholder="请输入密码">
  25. </div>
  26. <div class="input-group btn-group">
  27. <button>登录</button>
  28. </div>
  29. </form>
  30. <p>&copy;xx集团&nbsp;版权所有</p>
  31. </div>
  32.  
  33. </body>
  34. </html>
  35.  

reset.css部分(重置部分)

  1. *{
  2. margin:0;
  3. padding:0;
  4. }
  5. a{
  6. font-size: 12px;
  7. text-decoration: 0;
  8. color:#222;
  9. }
  10. a,
  11. input,
  12. button{
  13. outline: none;
  14. }
  15. ul,ol,li{
  16. list-style: none;
  17. }
  18. h1,h2,h3,h4,h5,h6{
  19. font-weight: 100;
  20. }
  21. img{
  22. display: block;
  23. border: 0;
  24. }

关于重置样式文件:

因为不同的浏览器对html标签的渲染有各自不同,即使开发者不对html页面写一行css代码,打开的页面也总会存在样式,但不同的浏览器的默认样式略有不同,这在一定程度上给开发者创造了麻烦,所以一般在开始写css代码的之前总是会先重置样式表,使得所有浏览器中html元素的样式统一,前端工程师通过自定义样式文件进行样式的统一,从而提高了前端界面的兼容性。

login.css部分

  1. y{
  2. background: rgba(0,0,0,0.8);
  3. }
  4. body{
  5. //为网页设置背景图片
  6. background-image: url(../img/xx.jpg);
  7. }
  8. .wrap{
  9. //使界面主体在浏览器居中
  10. position: absolute;//绝对定位
  11. left: 50%;
  12. top: 50%;
  13. margin: -175px 0 0 -250px;
  14. padding: 20px;
  15. width: 500px;
  16. height: 350px;
  17. background: #333333;
  18. box-shadow:0 0 10px rgba(255,255,255,0.5);
  19. box-sizing: border-box;//padding和border被包含在定义的width和height之内
  20. }
  21. h1{
  22. height: 50px;
  23. font-size: 1.6em;
  24. text-align: center;
  25. border-bottom: 1px solid rgba(255,255,255,0.5);
  26. }
  27. .input-group{
  28. margin: 20px auto;
  29. height: 40px;
  30. width: 300px;
  31. border: 1px solid rgba(0,0,0,0.2);
  32. }
  33. i{
  34. float: left;//左浮
  35. width: 40px;
  36. height: 40px;
  37. text-align: center;
  38. line-height: 40px !important;
  39. background: rgb(22,160,93);
  40. color: #fff;
  41. font-size: 22px !important;
  42. }
  43. .form-control{
  44. float: left;
  45. padding: 0 10px;
  46. height: 40px;
  47. border: 0;
  48. width: 260px;
  49. font-size: 18px;
  50. box-sizing: border-box;
  51. }
  52. .btn-group{
  53. border: 0;
  54. margin-top: 40px;
  55. }
  56. button{
  57. display: block;
  58. width: 100%;
  59. height: 40px;
  60. font-size: 1.2em;
  61. letter-spacing: 10px;
  62. border: 1px solid rgb(22,160,93);
  63. color: rgb(22,160,93);
  64. background: #fff;
  65. cursor: pointer;
  66. }
  67. button:hover{
  68. //为按钮元素设置鼠标悬浮的动态效果
  69. color: #fff;
  70. background: rgb(22,160,93);
  71. }
  72. p{
  73. font-size: 12px;
  74. text-align: center;
  75. color: #888;
  76. }

设计结果在浏览器上的效果:

到此这篇关于使用css样式设计一个简单的html登陆界面的实现的文章就介绍到这了,更多相关css html登陆界面内容请搜索w3xue以前的文章或继续浏览下面的相关文章,希望大家以后多多支持w3xue!

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号