很好,现在协助我编写登录界面代码吧使用HTML、CSS、JavaScript。HTML文件名为login.html。CSS文件名为login.css。JavaScript文件名为login.js。布局...
时间: 2024-03-15 17:47:33 浏览: 149
好的,下面是一个简单的登录界面代码,你可以参考一下:
HTML代码(login.html):
```html
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<link rel="stylesheet" type="text/css" href="login.css">
</head>
<body>
<div class="login-box">
<h2>Login Here</h2>
<form>
<div class="user-box">
<input type="text" name="" required="">
<label>Username</label>
</div>
<div class="user-box">
<input type="password" name="" required="">
<label>Password</label>
</div>
<a href="#">
<span></span>
<span></span>
<span></span>
<span></span>
Submit
</a>
</form>
</div>
<script type="text/javascript" src="login.js"></script>
</body>
</html>
```
CSS代码(login.css):
```css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #333;
font-family: sans-serif;
}
.login-box {
width: 280px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #fff;
}
.login-box h2 {
text-align: center;
margin-bottom: 30px;
}
.user-box {
position: relative;
}
.user-box input {
width: 100%;
padding: 10px 0;
font-size: 16px;
color: #fff;
border: none;
border-bottom: 1px solid #fff;
outline: none;
background: transparent;
}
.user-box label {
position: absolute;
top: 0;
left: 0;
font-size: 16px;
color: #fff;
pointer-events: none;
transition: 0.5s;
}
.user-box input:focus ~ label,
.user-box input:valid ~ label {
top: -20px;
left: 0;
color: #03a9f4;
font-size: 12px;
}
a {
display: inline-block;
background: #03a9f4;
border: none;
color: #fff;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
margin-top: 20px;
position: relative;
overflow: hidden;
transition: 0.5s;
}
a:hover {
background: #fff;
color: #03a9f4;
}
a span {
position: absolute;
display: block;
height: 100%;
width: 100%;
top: 0;
left: -100%;
background: #03a9f4;
transition: 0.5s;
}
a:hover span {
left: 0;
}
a span:nth-child(2) {
top: -100%;
transform: rotate(360deg);
}
a:hover span:nth-child(2) {
top: 0;
transform: rotate(0deg);
}
a span:nth-child(3) {
right: -100%;
transform: rotate(360deg);
}
a:hover span:nth-child(3) {
right: 0;
transform: rotate(0deg);
}
a span:nth-child(4) {
bottom: -100%;
transform: rotate(360deg);
}
a:hover span:nth-child(4) {
bottom: 0;
transform: rotate(0deg);
}
```
JavaScript代码(login.js):
```javascript
const inputs = document.querySelectorAll(".user-box input");
function focusFunc() {
let parent = this.parentNode;
parent.classList.add("focus");
}
function blurFunc() {
let parent = this.parentNode;
if (this.value == "") {
parent.classList.remove("focus");
}
}
inputs.forEach(input => {
input.addEventListener("focus", focusFunc);
input.addEventListener("blur", blurFunc);
});
```
这是一个简单的登录界面,使用了HTML、CSS、JavaScript实现。在这个界面中,我们使用了CSS的伪类选择器和动画效果来美化界面,使用了JavaScript来添加输入框的动态效果。
阅读全文