hbuilderx登录界面代码
时间: 2024-08-14 21:02:12 浏览: 48
HBuilderX uni-app登录实例.zip
HBuilderX是一个基于Eclipse的前端开发工具,它的登录界面通常会涉及HTML、CSS和JavaScript的配合。下面是一个简单的HBuilderX登录界面代码示例:
```html
<!-- login.html -->
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>登录 - HBuilderX 示例</title>
<link rel="stylesheet" href="styles.css"> <!-- 引入样式文件 -->
</head>
<body>
<div class="login-container">
<form id="loginForm">
<label for="username">用户名:</label>
<input type="text" id="username" name="username" required>
<br>
<label for="password">密码:</label>
<input type="password" id="password" name="password" required>
<br>
<button type="submit">登录</button>
<a href="#" class="forgot-password">忘记密码?</a>
</form>
</div>
<script src="scripts.js"> <!-- 引入脚本文件 -->
</script>
</body>
</html>
```
```css (styles.css)
/* styles.css */
.login-container {
width: 300px;
margin: auto;
padding: 20px;
border: 1px solid #ccc;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}
form {
display: flex;
flex-direction: column;
}
```
```javascript (scripts.js)
// scripts.js
document.getElementById('loginForm').addEventListener('submit', function(event) {
event.preventDefault(); // 阻止表单默认提交行为
// 这里只是一个模拟,实际应用中你需要发送AJAX请求到服务器验证
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
if (username === 'admin' && password === 'password') {
alert('登录成功');
} else {
alert('用户名或密码错误');
}
});
```
阅读全文