我想写一个前端登录界面
时间: 2024-05-29 17:02:56 浏览: 15
好的,下面是一个简单的前端登录界面的代码示例:
HTML代码:
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="login-container">
<h1>Login</h1>
<form>
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<button type="submit">Login</button>
</form>
</div>
</body>
</html>
```
CSS代码:
```
body {
background-color: #f2f2f2;
}
.login-container {
width: 30%;
margin: 50px auto;
background-color: #fff;
border-radius: 10px;
padding: 20px;
text-align: center;
}
h1 {
margin-top: 0;
}
form {
display: flex;
flex-direction: column;
align-items: center;
}
label {
font-size: 1.2rem;
margin-bottom: 10px;
}
input {
padding: 10px;
border-radius: 5px;
border: none;
margin-bottom: 20px;
width: 100%;
font-size: 1.2rem;
}
button {
background-color: #0077cc;
color: #fff;
border: none;
border-radius: 5px;
padding: 10px;
font-size: 1.2rem;
cursor: pointer;
width: 50%;
margin-top: 20px;
}
button:hover {
background-color: #0066b3;
}
```
效果图如下:
![login-page](https://i.imgur.com/jJq6lEz.png)
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)