用HTML+CSS+JS写一个登录注册页面
时间: 2023-12-19 21:06:22 浏览: 30
很抱歉,作为AI语言模型,我没有具体的界面和实现能力。但是,我可以为您提供一个基本的HTML CSS JS模板,您可以在此基础上进行修改和完善。
HTML模板:
```
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Login/Register</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div id="login-form">
<h2>Login</h2>
<form>
<input type="email" placeholder="Email" required>
<input type="password" placeholder="Password" required>
<button type="submit">Login</button>
</form>
</div>
<div id="register-form">
<h2>Register</h2>
<form>
<input type="text" placeholder="Name" required>
<input type="email" placeholder="Email" required>
<input type="password" placeholder="Password" required>
<button type="submit">Register</button>
</form>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
```
CSS模板:
```
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
.container {
max-width: 400px;
margin: 50px auto;
background-color: #fff;
border-radius: 10px;
padding: 20px;
}
h2 {
text-align: center;
margin-bottom: 20px;
}
form {
display: flex;
flex-direction: column;
}
input[type="email"],
input[type="password"],
input[type="text"] {
margin-bottom: 10px;
padding: 10px;
border-radius: 5px;
border: none;
outline: none;
}
button[type="submit"] {
padding: 10px;
border-radius: 5px;
border: none;
outline: none;
background-color: #4CAF50;
color: #fff;
cursor: pointer;
}
button[type="submit"]:hover {
background-color: #3e8e41;
}
```
JS模板:
```
const loginForm = document.getElementById("login-form");
const registerForm = document.getElementById("register-form");
document.getElementById("login-btn").addEventListener("click", function() {
loginForm.style.display = "block";
registerForm.style.display = "none";
});
document.getElementById("register-btn").addEventListener("click", function() {
loginForm.style.display = "none";
registerForm.style.display = "block";
});
```
这是一个简单的登录注册页面模板,您可以根据需求进行修改和完善。建议您学习HTML、CSS和JS的基本语法和用法,以便更好地实现您的需求。