html+js+css登录注册界面
以下是一个简单的HTML、JavaScript和CSS结合的登录注册界面示例:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login & Register Form</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<section class="container">
<div class="login-box">
<form id="login-form" autocomplete="off">
<h2>Login</h2>
<div class="input-group">
<input type="text" required>
<label>Username</label>
</div>
<div class="input-group">
<input type="password" required>
<label>Password</label>
</div>
<button type="submit" class="btn">Login</button>
</form>
<form id="register-form" autocomplete="off">
<h2>Register</h2>
<div class="input-group">
<input type="text" required>
<label>Username</label>
</div>
<div class="input-group">
<input type="email" required>
<label>Email</label>
</div>
<div class="input-group">
<input type="password" required>
<label>Password</label>
</div>
<button type="submit" class="btn">Register</button>
</form>
</div>
</section>
<script src="script.js"></script>
</body>
</html>
CSS (style.css):
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: #28a745;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.container {
width: 100%;
max-width: 400px;
}
.login-box {
width: 100%;
max-width: 400px;
background-color: #fff;
padding: 30px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 5px;
position: relative;
}
.input-group {
margin: 10px 0;
}
.input-group input {
width: calc(100% - 10px);
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
font-size: 16px;
}
.input-group label {
position: absolute;
top: 0;
left: 10px;
padding: 10px;
pointer-events: none;
transition: 0.5s;
font-size: 16px;
}
.input-group input:focus ~ label,
.input-group input:valid ~ label {
top: -20px;
color: #28a745;
font-size: 12px;
}
.btn {
width: calc(100% - 20px);
padding: 10px;
margin: 10px 0;
background-color: #28a745;
评论已关闭