CSS+HTML 书写前端Login
开始Login会有一个自定义下坠动画,大神勿喷,一共是两张,一张登录一张注册
效果图
代码
Login.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>软帝登录</title>
<link rel="stylesheet" href="css/login.css">
<link rel="shortcut icon" href="./img/icon.jpeg" type="image/x-icon">
</head>
<body>
<main id="login">
<h1>Login</h1>
<form action="loginServlet">
<input type="text" placeholder="username" name="username">
<input type="password" placeholder="password" name="password">
<div class="button-div">
<button class="login-button">Login</button>
</div>
<div class="account">
Don't hava account?<a href="register.html" class="Sing-a" id="toregister">Sign up</a>
</div>
</form>
</main>
</body>
<script src="./js/login.js"></script>
</html>
Login.css
* {
margin: 0;
padding: 0;
border: 0;
box-sizing: border-box;
}
/* 设置背景颜色 */
body {
width: 100vw;
height: 100vh;
background-image: linear-gradient(to right, #fbc2eb, #a6c1ee);
}
main {
width: 500px;
height: 600px;
background-color: #fff;
border-radius: 20px;
position: relative;
top: calc(50% - 300px);
margin: 0 auto;
animation: identifier .5s ease-in;
}
/* 自定义下坠动画 */
@keyframes identifier {
0% {
top: -600px;
}
60% {
top: calc(50% - 300px);
}
80% {
top: calc(50% - 350px);
}
100% {
top: calc(50% - 300px);
}
}
main>h1 {
height: 150px;
line-height: 150px;
text-align: center;
font-size: 38px;
font-weight: bold;
}
input {
display: block;
width: 80%;
margin-bottom: 20px;
border: 0;
padding: 10px;
margin: 50px auto;
border-bottom: 1px solid rgba(128, 125, 125, 0.425);
font-size: 20px;
outline: none;
color: pink;
}
.button-div {
width: 80%;
height: 50px;
margin: 40px auto;
}
.login-button {
width: 100%;
height: 100%;
color: #fff;
font-size: 25px;
background-image: linear-gradient(to right, #fbc2eb, #a6c1ee);
}
.account {
text-align: center;
font-size: 20px;
}
.Sing-a {
margin-left: 10px;
/* 取消下划线 */
text-decoration: none;
/* 字体颜色 */
color: rgba(0, 0, 255, 0.507);
}
Reg.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>软帝注册</title>
<link rel="stylesheet" href="./css/register.css">
<link rel="shortcut icon" href="./img/icon.jpeg" type="image/x-icon">
</head>
<body>
<main id="reg">
<h1>Register</h1>
<form action="">
<input type="text" class="input-item" placeholder="username">
<p class="confirm"> </p>
<input type="text" class="input-item" placeholder="password">
<p class="confirm"> </p>
<input type="text" class="input-item" placeholder="confirm password">
<p class="confirm"> </p>
<div class="security-div">
<input type="text" class="input-item security" placeholder="security code" >
<img src="./img/renren_code.gif" alt="" class="security-img">
</div>
<div class="button">
<button>Register</button>
<p>Existing account,Return to the <a href="login.html" id="tologin">login</a> </p>
</div>
</form>
</main>
</body>
</html>
reg.css
* {
margin: 0;
padding: 0;
border: 0;
/* 设置怪异盒子 */
box-sizing: border-box;
}
body {
width: 100vw;
height: 100vh;
background-image: linear-gradient(to right, #fbc2eb, #a6c1ee);
}
main {
width: 500px;
height: 600px;
background-color: #fff;
border-radius: 20px;
position: relative;
top: calc(50% - 300px);
margin: 0 auto;
}
main>h1 {
height: 100px;
line-height: 100px;
text-align: center;
font-size: 38px;
font-weight: bold;
}
.input-item {
display: block;
width: 80%;
height: 50px;
border-radius: 5px;
outline: none;
border: 0;
border-bottom: 1px solid rgba(128, 125, 125, 0.425);
font-size: 20px;
color: pink;
margin: 0px auto;
padding-left: 10px;
}
.confirm {
width: 80%;
margin: 10px auto;
}
.security{
display: inline-block;
width: 40%;
margin-left: 50px;
}
.security{
width: 50%;
height: 100%;
}
.security-img{
width: 25%;
}
.button{
width: 80%;
height: 50px;
margin: 0 auto;
}
.button>button{
width: 100%;
height: 100%;
margin-top: 30px;
border-radius: 10px;
color: #fff;
font-size: 20px;
background-image: linear-gradient(to right, #fbc2eb, #a6c1ee);
outline: none;
}
.button>p{
text-align: center;
margin-top: 30px;
}
.button>p>a{
text-decoration: none;
color: rgba(0, 0, 255, 0.589);
font-size: 20px;
}