当然,下面是一个稍微改进了布局的示例代码:
<!DOCTYPE html>
<html>
<head>
<title>登录</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
.container {
width: 300px;
margin: 0 auto;
padding: 20px;
background-color: white;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
}
form {
margin-top: 20px;
}
label {
display:block;
margin-bottom:10px;
}
input[type="text"],
input[type="password"] {
width:100%;
padding:10px;
border-radius:3px;
border:solid 1px #ccc;
}
button[type="submit"] {
width:auto;
margin-top:20px;
padding:.5em;
background-color:#4CAF50;
color:white;
border:none;
cursor:pointer;
}
button[type="submit"]:hover {opacity:.7;}
</style>
</head>
<body>
<div class="container">
<h1>登录</h1>
<form action="" method="post">
<label for="username">用户名:</label>
<input type="text" id="username" name="username" value="admin">
<label for="password">密码:</label>
<input type="password" id="password" name="password" value="admin">
<button type="submit">登录</button>
</form>
</div>
<script>
// JavaScript代码可以在这里添加,用于处理表单提交等其他交互逻辑
</script>
</body>
</html>
这个示例将输入框和按钮放置在一个带有边框和阴影的容器中,并且使用了稍微改进的布局。你也可以根据需求继续调整样式和布局。
内容由零声教学AI助手提供,问题来源于学员提问