HTML(HyperText Markup Language)是一种用于创建网页的标准标记语言,而CSS(Cascading Style Sheets)则用于描述网页的外观和格式。登录模板通常包括用户名和密码输入框,以及一个提交按钮。
以下是一个简单的HTML & CSS登录模板示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Page</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f4f4f4;
}
.login-container {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
}
.form-group input {
width: 100%;
padding: 8px;
box-sizing: border-box;
}
.btn-login {
width: 100%;
padding: 10px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}
.btn-login:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="login-container">
<form action="#" method="post">
<div class="form-group">
<label for="username">Username</label>
<input type="text" id="username" name="username" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" required>
</div>
<button type="submit" class="btn-login">Login</button>
</form>
</div>
</body>
</html>原因:
action属性未正确设置。解决方法:
确保action属性指向正确的处理URL,并在服务器端编写相应的处理逻辑。
<form action="/login" method="post">
<!-- 表单内容 -->
</form>原因:
解决方法: 检查CSS选择器是否正确,并确保CSS文件已正确引入。
<link rel="stylesheet" href="styles.css">通过以上示例和解释,你应该能够创建一个基本的HTML & CSS登录模板,并解决一些常见问题。
没有搜到相关的文章