vscode:Web前端——登录、注册界面代码
时间: 2023-08-23 14:06:03 浏览: 1891
前端代码+登陆与注册
好的,以下是一个简单的登录、注册界面的示例代码,供你参考:
HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>Login/Register</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
<div class="form-container">
<h2>Login</h2>
<form>
<label for="username">Username:</label>
<input type="text" id="username" name="username" placeholder="Enter username">
<label for="password">Password:</label>
<input type="password" id="password" name="password" placeholder="Enter password">
<button type="submit">Login</button>
</form>
</div>
<div class="form-container">
<h2>Register</h2>
<form>
<label for="reg-username">Username:</label>
<input type="text" id="reg-username" name="reg-username" placeholder="Enter username">
<label for="reg-password">Password:</label>
<input type="password" id="reg-password" name="reg-password" placeholder="Enter password">
<label for="confirm-password">Confirm Password:</label>
<input type="password" id="confirm-password" name="confirm-password" placeholder="Enter password again">
<button type="submit">Register</button>
</form>
</div>
</div>
</body>
</html>
```
CSS代码:
```css
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
.container {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
height: 100vh;
}
.form-container {
background-color: #fff;
margin: 10px;
padding: 20px;
border-radius: 5px;
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.2);
}
.form-container h2 {
margin-bottom: 10px;
}
form {
display: flex;
flex-direction: column;
}
label {
margin-top: 10px;
}
input {
padding: 5px;
margin-top: 5px;
border: 1px solid #ccc;
border-radius: 3px;
}
button {
background-color: #4CAF50;
color: #fff;
padding: 10px;
margin-top: 10px;
border: none;
border-radius: 3px;
cursor: pointer;
}
button:hover {
background-color: #3e8e41;
}
```
以上代码实现了一个简单的登录、注册界面,包含输入框、按钮等基本元素,并使用CSS样式美化页面。你可以在本地创建一个HTML和CSS文件,将代码复制到对应文件中,然后使用浏览器打开HTML文件,查看效果。当然,这只是一个简单的示例,实际的登录、注册功能需要更复杂的代码实现。
阅读全文