<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>登录</title> </head> <body> <style> body { background-image: url(C.jpg); background-repeat: no-repeat; background-size: cover; } </style> <center> <h1>登录</h1> </center> <?php if(isset($error_message)): ?> <p style="color:red"><?php echo $error_message; ?></p> <?php endif; ?> <form action="" method="post"> <div> <label for="username">用户名:</label> <input type="text" id="username" name="username"> </div> <div> <label for="password">密码:</label> <input type="password" id="password" name="password"> </div> <div> <button type="submit">登录</button> </div> </form> </body> </html> 可以帮我美化一下布局吗
时间: 2023-11-16 16:46:57 浏览: 47
当然可以帮您美化一下布局。以下是对您提供的代码进行了一些布局和样式方面的改进:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录</title>
<style>
body {
background-image: url(C.jpg);
background-repeat: no-repeat;
background-size: cover;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: Arial, sans-serif;
}
.login-container {
background-color: #fff;
padding: 20px;
border-radius: 5px;
}
.login-container h1 {
text-align: center;
}
.login-container form {
margin-top: 20px;
}
.login-container label {
display: block;
}
.login-container input[type="text"],
.login-container input[type="password"] {
width: 100%;
padding: 10px;
margin-bottom: 10px;
}
.login-container button[type="submit"] {
background-color: #4CAF50;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
}
.login-container button[type="submit"]:hover {
background-color: #45a049;
}
.error-message {
color: red;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="login-container">
<h1>登录</h1>
<?php if(isset($error_message)): ?>
<p class="error-message"><?php echo $error_message; ?></p>
<?php endif; ?>
<form action="" method="post">
<div>
<label for="username">用户名:</label>
<input type="text" id="username" name="username">
</div>
<div>
<label for="password">密码:</label>
<input type="password" id="password" name="password">
</div>
<div>
<button type="submit">登录</button>
</div>
</form>
</div>
</body>
</html>
```
在这个示例中,我给容器添加了一个名为 `.login-container` 的类,并为其设置了一些样式,包括背景颜色、内边距、边框半径等。我还添加了一些样式来调整输入框、标签和按钮的样式。同时,为错误提示信息也添加了一个名为 `.error-message` 的类,并设置了一些相关样式。
请注意,这仅是一个简单的布局美化示例,您可以根据需要进一步自定义样式。希望对您有所帮助!