以下是一个简化的HTML和JavaScript代码示例,用于实现上述登录窗口的功能:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Window</title>
<style>
body, html {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background: #2e4053;
}
.login-container {
width: 300px;
padding: 40px;
background: #fff;
border-radius: 8px;
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}
.login-container h2 {
text-align: center;
}
.form-group {
margin-bottom: 15px;
}
.form-group input[type="text"], .form-group input[type="password"] {
width: 100%;
padding: 15px;
margin-top: 30px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
.form-group input[type="submit"] {
width: 100%;
padding: 15px;
border: none;
border-radius: 4px;
background: #58a9ff;
color: #fff;
cursor: pointer;
}
.form-group input[type="submit"]:hover {
background: #4e8ab3;
}
</style>
</head>
<body>
<div class="login-container">
<h2>Login to your Account</h2>
<form action="">
<div class="form-group">
<input type="text" required autocomplete="off" placeholder="Username" name="username" />
</div>
<div class="form-group">
<input type="password" required placeholder="Password" name="password" />
</div>
<div class="form-group">
<input type="submit" value="Login" />
</div>
</form>
</div>
<script>
// JavaScript code to handle the login form submission
document.querySelector('form').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the form from submitting
const username = document.querySelector('input[name="username"]').value;
const password = document.querySelector('input[name="password"]').value;
// Here you would handle the login logic, e.g., by sending a request to the server
// For now, we'll just log the username and password to the console
console.log('Login attempt with username: ' + username + ' and passwor