html css 登陆界面代码
时间: 2023-10-20 14:03:21 浏览: 67
HTML代码:
<!DOCTYPE html>
<html>
<head>
<title>登录界面</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
<h1>登录</h1>
<form action="login.php" 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>
CSS代码(style.css):
.container {
width: 300px;
margin: 0 auto;
padding: 20px;
background: #f2f2f2;
border: 1px solid #ccc;
border-radius: 5px;
}
h1 {
text-align: center;
color: #333;
}
label {
display: block;
margin-bottom: 5px;
color: #555;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 8px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}
input[type="submit"] {
width: 100%;
padding: 10px;
background: #4CAF50;
color: #fff;
border: none;
border-radius: 4px;
}
以上代码展示了一个基本的登录界面。在HTML中,使用form元素创建一个表单用于用户输入用户名和密码。在CSS中,设置了容器的样式,包括宽度、边距和背景颜色。使用了居中对齐的标题和标签来标识输入字段的描述。输入字段和提交按钮设置了样式,包括宽度、填充、边框和边框半径。当用户输入用户名和密码后,点击提交按钮会将数据发送到login.php处理登录逻辑。