继续优化帮我设计出更加美观的界面<!DOCTYPE html> <html> <head> <title>Login</title> <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <style> form { display: flex; flex-direction: column; align-items: center; margin-top: 20px; } label { font-size: 18px; margin-bottom: 5px; } input[type=text], input[type=password] { padding: 10px; border-radius: 5px; border: none; margin-bottom: 20px; width: 300px; } input[type=button] { background-color: #4CAF50; color: white; border: none; border-radius: 5px; padding: 10px 20px; cursor: pointer; font-size: 18px; margin-bottom: 20px; width: 300px; } input[type=button]:hover { background-color: #3e8e41; } h1 { text-align: center; margin-top: 50px; font-size: 36px; } </style> </head> <body> <h1>Login</h1> <form> <label for="username">Username:</label> <input type="text" id="username" name="username"> <label for="password">Password:</label> <input type="password" id="password" name="password"> <input type="button" id="submit" value="Submit"> </form> <script> $(document).ready(function() { $("#submit").click(function() { var username = $("#username").val(); var password = $("#password").val(); $.ajax({ url: "/login", type: "POST", data: { username: username, password: password }, success: function(response) { if (response == "success") { window.location.href = "/dashboard"; } else { alert("Invalid username or password."); } }, error: function() { alert("Error occurred."); } }); }); }); </script> </body> </html>
时间: 2024-01-06 10:04:24 浏览: 24
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<style>
body {
background-color: #f2f2f2;
}
form {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 50px;
background-color: #ffffff;
padding: 50px;
border-radius: 10px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
label {
font-size: 18px;
margin-bottom: 5px;
}
input[type=text],
input[type=password] {
padding: 10px;
border-radius: 5px;
border: none;
margin-bottom: 20px;
width: 300px;
}
input[type=button] {
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
padding: 10px 20px;
cursor: pointer;
font-size: 18px;
margin-bottom: 20px;
width: 300px;
}
input[type=button]:hover {
background-color: #3e8e41;
}
h1 {
text-align: center;
margin-top: 50px;
font-size: 36px;
color: #4CAF50;
}
</style>
</head>
<body>
<h1>Login</h1>
<form>
<label for="username">Username:</label>
<input type="text" id="username" name="username">
<label for="password">Password:</label>
<input type="password" id="password" name="password">
<input type="button" id="submit" value="Submit">
</form>
<script>
$(document).ready(function() {
$("#submit").click(function() {
var username = $("#username").val();
var password = $("#password").val();
$.ajax({
url: "/login",
type: "POST",
data: { username: username, password: password },
success: function(response) {
if (response == "success") {
window.location.href = "/dashboard";
} else {
alert("Invalid username or password.");
}
},
error: function() {
alert("Error occurred.");
}
});
});
});
</script>
</body>
</html>