html css js注册界面
时间: 2023-09-20 21:10:26 浏览: 43
好的,以下是一个简单的 HTML、CSS、JavaScript 注册界面的示例代码:
HTML:
```
<!DOCTYPE html>
<html>
<head>
<title>注册界面</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
<form>
<h1>注册</h1>
<label for="username">用户名</label>
<input type="text" id="username" name="username" required>
<label for="password">密码</label>
<input type="password" id="password" name="password" required>
<label for="confirm-password">确认密码</label>
<input type="password" id="confirm-password" name="confirm-password" required>
<label for="email">邮箱</label>
<input type="email" id="email" name="email" required>
<button type="submit">注册</button>
</form>
</div>
<script src="script.js"></script>
</body>
</html>
```
CSS:
```
.container {
margin: 50px auto;
max-width: 500px;
padding: 20px;
background-color: #f2f2f2;
border-radius: 10px;
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.2);
}
form {
display: flex;
flex-direction: column;
}
h1 {
text-align: center;
margin-bottom: 20px;
}
label {
font-size: 18px;
margin-bottom: 10px;
}
input {
padding: 10px;
margin-bottom: 20px;
font-size: 16px;
border-radius: 5px;
border: none;
background-color: #e6e6e6;
}
button {
padding: 10px;
margin-top: 20px;
font-size: 18px;
border-radius: 5px;
border: none;
background-color: #4CAF50;
color: #fff;
cursor: pointer;
}
button:hover {
background-color: #3e8e41;
}
```
JavaScript:
```
const form = document.querySelector('form');
const password = document.getElementById('password');
const confirm_password = document.getElementById('confirm-password');
form.addEventListener('submit', (event) => {
if (password.value !== confirm_password.value) {
event.preventDefault();
alert('两次输入的密码不一致');
}
});
```
这个注册界面包括用户名、密码、确认密码和邮箱四个字段,其中密码和确认密码需要一致才能提交表单。你可以根据自己的需求进行修改和优化。