下面是一个简单的登录页面的HTML代码:
<!DOCTYPE html>
<html>
<head>
<title>登录页面</title>
<style>
/* 添加样式 */
.container {
width: 500px;
margin: 0 auto;
text-align: center;
}
input[type="text"], input[type="password"] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
}
input[type="submit"] {
width: 100%;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="container">
<h2>登录</h2>
<form action="/login" method="post">
<label for="username">用户名</label>
<input type="text" id="username" name="username" required>
<br>
<label for="password">密码</label>
<input type="password" id="password" name="password" required>
<br>
<input type="submit" value="登录">
</form>
</div>
</body>
</html>
该登录页面由一个表单构成,包括用户名和密码两个输入框以及一个提交按钮。通过 <label>
标签和 for
属性将每个输入框与其相应的标签相关联。通过 CSS 样式,可以调整输入框的外观和按钮的样式。