HTML和CSS实现炫酷的登录页面

效果图:在这里插入图片描述

HTML

  整个页面元素很简单就不细讲了,直接上代码吧:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Login</title>
  <link rel="stylesheet" href="../css/Login.css">
  <link rel="stylesheet" href="D:/font-awesome-4.7.0/css/font-awesome.css">
</head>
<body>
  <div id="login-box">
    <form action="">
      <h1>Login</h1>
      <div class="form">
        <div class="item">
          <i class="fa fa-user-circle-o" aria-hidden="true"></i>
          <input type="text" placeholder="Username" required />
        </div>
        <div class="item">
          <i class="fa fa-key" aria-hidden="true"></i>
          <input type="password" placeholder="Password" required />
        </div>
      </div>
      <button type="submit">Login</button>
    </form>
  </div>
</body>
</html>

  上面两个link一个是引用css文件,一个是引用一个图标库font-awesome,大家可以去百度搜一下,然后直接下载,在项目中引用就能用了。

CSS

我们要解决这几件事:

  • 半透明框体
  • 框体居中且里面的文字等元素也居中
  • 背景图全屏铺满
  • 输入框的边框只有下边框
  • 按钮的圆角与渐变色

代码如下:

body{
  background: url('../img/img03.jpg');
  background-repeat: no-repeat;
  background-size: 100% auto;
}

#login-box{
  width: 30%;
  height: auto;
  margin: 0 auto;
  margin-top: 15%;
  text-align: center;
  background: #00000090;
  padding: 20px 50px;
}

#login-box h1{
  color: #fff;
}

#login-box .form .item{
  margin-top: 15px;
}

#login-box .form .item i{
  font-size: 18px;
  color: #fff;
}

#login-box .form .item input{
  width: 180px;
  font-size: 18px;
  border: 0;
  border-bottom: 2px solid #fff;
  padding: 5px 10px;
  background: #ffffff00;
  color: #fff;
}
#login-box button{
  margin-top: 15px;
  width: 180px;
  height: 30px;
  font-size: 20px;
  font-weight: 400;
  color: #fff;
  border: 0;
  border-radius: 15px;
  /* background: #1abc9c; */
  /* background-image: linear-gradient(to right, #43e97b 0%, #38f9d7 100%); */
  background-image: linear-gradient(to right, #e4afcb 0%, #b8cbb8 0%, #b8cbb8 0%, #e2c58b 30%, #c2ce9c 64%, #7edbdc 100%);
}

渐变色是从网站webgradients.com直接复制的(你也可以自己手动改)

  • 21
    点赞
  • 110
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
好的,以下是一个简单的学生选课系统登录页面HTMLCSS实现炫酷登录页面代码: HTML代码: ```html <!DOCTYPE html> <html> <head> <title>学生选课系统登录</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div class="login-box"> <h2>学生选课系统登录</h2> <form> <div class="user-box"> <input type="text" name="" required=""> <label>用户名</label> </div> <div class="user-box"> <input type="password" name="" required=""> <label>密码</label> </div> <a href="#"> <span></span> <span></span> <span></span> <span></span> 提交 </a> </form> </div> </body> </html> ``` CSS代码: ```css * { margin: 0; padding: 0; box-sizing: border-box; font-family: sans-serif; } body { background: #f2f2f2; } .login-box { width: 280px; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #191919; padding: 40px; border-radius: 10px; box-shadow: 0 0 20px 0 rgba(0,0,0,0.2); } .login-box h2 { color: #fff; text-align: center; margin-bottom: 30px; text-transform: uppercase; font-weight: 400; } .login-box .user-box { position: relative; } .login-box .user-box input { width: 100%; padding: 10px 0; font-size: 16px; color: #fff; margin-bottom: 30px; border: none; border-bottom: 1px solid #fff; outline: none; background: transparent; } .login-box .user-box label { position: absolute; top: 0; left: 0; padding: 10px 0; font-size: 16px; color: #fff; pointer-events: none; transition: 0.5s; } .login-box .user-box input:focus ~ label, .login-box .user-box input:valid ~ label { top: -20px; left: 0; color: #03a9f4; font-size: 12px; } .login-box a { display: inline-block; background: #03a9f4; color: #fff; padding: 10px 20px; border-radius: 5px; text-decoration: none; margin-top: 30px; transition: 0.5s; } .login-box a:hover { background: #fff; color: #03a9f4; } ``` 这个登录页面使用了HTML的表单元素和CSS的伪类选择器,实现了输入框动态效果和按钮的 hover 效果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值