用html+CSS做一个漂亮的注册界面
时间: 2023-06-17 18:07:17 浏览: 55
好的,以下是一个简单的注册页面的 HTML 和 CSS 代码:
HTML 代码:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>注册</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="container">
<form action="#">
<h2>注册</h2>
<div class="input-group">
<input type="text" id="name" required />
<label for="name">用户名</label>
</div>
<div class="input-group">
<input type="email" id="email" required />
<label for="email">邮箱</label>
</div>
<div class="input-group">
<input type="password" id="password" required />
<label for="password">密码</label>
</div>
<div class="input-group">
<input type="password" id="confirm-password" required />
<label for="confirm-password">确认密码</label>
</div>
<button type="submit">注册</button>
<p class="login">已有账号?<a href="#">登录</a></p>
</form>
</div>
</body>
</html>
```
CSS 代码:
```css
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: Arial, Helvetica, sans-serif;
background-color: #f1f1f1;
}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
form {
background-color: #fff;
padding: 40px;
border-radius: 10px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
margin-bottom: 30px;
}
.input-group {
position: relative;
margin-bottom: 30px;
}
input {
width: 100%;
padding: 10px 0px;
border: none;
border-bottom: 1px solid #ccc;
font-size: 16px;
font-weight: 500;
color: #333;
background-color: transparent;
}
label {
position: absolute;
top: 0px;
left: 0px;
font-size: 16px;
font-weight: 500;
color: #999;
pointer-events: none;
transition: all 0.2s ease-in-out;
}
input:focus + label,
input:not(:placeholder-shown) + label {
top: -20px;
font-size: 14px;
color: #333;
}
button {
width: 100%;
padding: 10px;
border: none;
border-radius: 5px;
background-color: #007bff;
color: #fff;
font-size: 16px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s ease-in-out;
}
button:hover {
background-color: #0069d9;
}
.login {
text-align: center;
margin-top: 20px;
}
.login a {
color: #007bff;
text-decoration: none;
}
```
你可以将 HTML 和 CSS 代码复制到自己的文件中,并在浏览器中查看效果。