帮我写个精美的登录页面
时间: 2023-10-03 13:05:28 浏览: 32
好的,下面是一个简单的登录页面的HTML和CSS代码示例:
HTML代码:
```
<!DOCTYPE html>
<html>
<head>
<title>登录页面</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="login-container">
<h1>欢迎登录</h1>
<form>
<label for="username">用户名</label>
<input type="text" id="username" placeholder="请输入用户名" required>
<label for="password">密码</label>
<input type="password" id="password" placeholder="请输入密码" required>
<button type="submit">登录</button>
</form>
</div>
</body>
</html>
```
CSS代码:
```
.login-container {
width: 380px;
margin: 0 auto;
padding: 20px;
border: 1px solid #ddd;
border-radius: 5px;
background-color: #fafafa;
}
h1 {
margin-top: 0;
text-align: center;
}
form {
display: flex;
flex-direction: column;
}
label {
margin-top: 10px;
}
input {
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
margin-bottom: 20px;
}
button {
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
button:hover {
background-color: #3e8e41;
}
```
你可以将上面的代码复制到一个HTML文件和CSS文件中,然后在浏览器中打开该HTML文件查看效果。当然,你也可以根据自己的需求进行样式和布局的修改。