html用户登录界面代码
时间: 2023-08-12 09:05:11 浏览: 44
以下是一个简单的 HTML 用户登录界面的代码示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>User Login</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
background-color: #f2f2f2;
}
form {
border: 2px solid #ccc;
background-color: #fff;
padding: 20px;
max-width: 400px;
margin: 50px auto;
border-radius: 5px;
}
input[type=text], input[type=password] {
padding: 10px;
width: 100%;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
border-radius: 4px;
}
button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
border-radius: 4px;
}
button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<form>
<h2>User Login</h2>
<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>
</body>
</html>
```
该代码包括一个表单,其中包含用户名和密码输入字段以及登录按钮。该表单使用 CSS 样式进行美化,包括背景色、边框、填充、圆角和按钮颜色。在输入字段中,我们使用了 "required" 属性来确保用户必须输入有效的用户名和密码才能提交表单。