给我用HTML和CSS写一个登录页面
时间: 2024-05-13 16:16:05 浏览: 13
好的,以下是一个使用HTML和CSS编写的基本登录页面:
HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Login Page</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="login-box">
<h1>Login</h1>
<form>
<label for="username">Username</label>
<input type="text" placeholder="Enter Username" id="username">
<label for="password">Password</label>
<input type="password" placeholder="Enter Password" id="password">
<input type="submit" value="Login">
<p>Don't have an account? <a href="#">Register here</a>.</p>
</form>
</div>
</body>
</html>
```
CSS代码:
```css
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
}
.login-box {
background-color: #fff;
border-radius: 5px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
padding: 30px;
margin: auto;
margin-top: 100px;
width: 400px;
max-width: 90%;
}
h1 {
text-align: center;
margin-bottom: 30px;
}
form {
display: flex;
flex-direction: column;
}
label {
font-weight: bold;
margin-bottom: 5px;
}
input[type="text"],
input[type="password"] {
padding: 10px;
border-radius: 5px;
margin-bottom: 20px;
border: none;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
padding: 10px;
border: none;
border-radius: 5px;
cursor: pointer;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
}
p {
text-align: center;
margin-top: 20px;
}
```
这个页面有一个标题和一个输入表单,其中包括用户名和密码的输入框以及一个登录按钮。如果用户没有帐户,还有一个链接可以注册帐户。登录框被放置在一个超过其大小的框中,并位于页面的中央,使其在不同屏幕大小的设备上仍然可见。通过使用CSS,登录框还具有阴影效果,以增加其深度感。