写一个复杂且华丽的登录页面,并且用到css和js
时间: 2023-02-09 21:48:52 浏览: 71
下面是一个简单的登录页面示例,使用了 HTML、CSS 和 JavaScript 来实现。
HTML 代码:
```html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="script.js"></script>
<title>登录页面</title>
</head>
<body>
<div class="container">
<form>
<h1>登录</h1>
<label for="username">用户名:</label>
<input type="text" id="username" name="username">
<br>
<label for="password">密码:</label>
<input type="password" id="password" name="password">
<br>
<input type="button" value="登录" onclick="check()">
</form>
</div>
</body>
</html>
```
CSS 代码:
```css
body {
background-color: #f2f2f2;
}
.container {
width: 400px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px #ccc;
}
form {
text-align: center;
}
input[type="text"], input[type="password"] {
width: 80%;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
}
input[type="button"] {
width: 80%;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type="button"]:hover {
background-color: #45a049;
}
h1 {
text-align: center;
margin-bottom: 30px;
}
```
JavaScript 代码:
```javascript
function check() {
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if (username == "admin" && password == "123456") {
alert("登录成功!");
} else {
alert("用户名或密码错误!");
}
}
```
这个示例使用了表单、文本框、密码框、按钮等基