我遇到一个问题: Font 'C:\Users\13009\Desktop\msyh.ttc' with 'Identity-H' is not recognized.
时间: 2023-05-22 07:01:40 浏览: 486
好的,以下是一个简单的登录页面的原生JS代码:
HTML代码:
```
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Login Page</h1>
<form>
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<button type="submit" id="login-btn">Login</button>
</form>
</div>
<script src="script.js"></script>
</body>
</html>
```
CSS代码:
```
.container {
max-width: 400px;
margin: 0 auto;
padding: 20px;
background-color: #f2f2f2;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}
h1 {
text-align: center;
margin-bottom: 20px;
}
form {
display: flex;
flex-direction: column;
}
label {
margin-bottom: 10px;
}
input {
padding: 10px;
margin-bottom: 20px;
border-radius: 5px;
border: none;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
button {
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #3e8e41;
}
```
JS代码:
```
const form = document.querySelector('form');
const usernameInput = document.querySelector('#username');
const passwordInput = document.querySelector('#password');
const loginBtn = document.querySelector('#login-btn');
form.addEventListener('submit', e => {
e.preventDefault();
const username = usernameInput.value.trim();
const password = passwordInput.value.trim();
if (username === '' || password === '') {
alert('Please enter both username and password.');
} else {
// Send login request to server
console.log(`Login request sent with username: ${username} and password: ${password}`);
}
});
```
这个登录页面包含一个表单,其中包含一个用户名输入框、一个密码输入框和一个登录按钮。当用户点击登录按钮时,JS代码会获取输入框中的值,并检查它们是否为空。如果输入框中有任何一个为空,JS代码会弹出一个警告框,提示用户输入用户名和密码。如果输入框中都有值,JS代码会向服务器发送登录请求,并在控制台中打印出用户名和密码。
阅读全文