使用HTML、CSS、JavaScript写一个华丽的登录页面
时间: 2023-10-15 21:05:56 浏览: 118
好的,我可以给你提供一个简单的示例,你可以根据自己的需求进行修改和完善。
HTML代码:
```
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<link rel="stylesheet" type="text/css" href="style.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>
</body>
</html>
```
CSS代码:
```
body {
margin: 0;
padding: 0;
background: linear-gradient(to top, #f3e7e9, #e3eeff);
}
.login-box {
width: 320px;
height: 420px;
background: #ffffff;
color: #000000;
top: 50%;
left: 50%;
position: absolute;
transform: translate(-50%, -50%);
box-sizing: border-box;
padding: 70px 30px;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0,0,0,.3);
}
h2 {
margin: 0;
padding: 0;
font-weight: 600;
font-size: 1.5em;
text-align: center;
margin-bottom: 30px;
}
.login-box .user-box {
position: relative;
}
.login-box .user-box input {
width: 100%;
padding: 10px 0;
font-size: 16px;
color: #000000;
margin-bottom: 30px;
border: none;
border-bottom: 1px solid #000000;
outline: none;
background: transparent;
}
.login-box .user-box label {
position: absolute;
top: 0;
left: 0;
padding: 10px 0;
font-size: 16px;
color: #000000;
pointer-events: none;
transition: .5s;
}
.login-box .user-box input:focus ~ label,
.login-box .user-box input:valid ~ label {
top: -20px;
left: 0;
color: #ff7e67;
font-size: 14px;
}
.login-box a {
display: inline-block;
background: #ff7e67;
color: #ffffff;
text-transform: uppercase;
border: none;
margin-top: 40px;
padding: 12px 30px;
cursor: pointer;
border-radius: 25px;
transition: 0.5s;
}
.login-box a:hover {
background: #ffffff;
color: #ff7e67;
}
.login-box a span {
position: absolute;
display: block;
}
.login-box a span:nth-child(1) {
top: 0;
left: -20px;
width: 20px;
height: 100%;
background: linear-gradient(to right, transparent, #ff7e67);
}
.login-box a span:nth-child(2) {
top: -20px;
right: 0;
width: 100%;
height: 20px;
background: linear-gradient(to bottom, transparent, #ff7e67);
}
.login-box a span:nth-child(3) {
bottom: 0;
right: -20px;
width: 20px;
height: 100%;
background: linear-gradient(to left, transparent, #ff7e67);
}
.login-box a span:nth-child(4) {
top: -20px;
left: 0;
width: 100%;
height: 20px;
background: linear-gradient(to top, transparent, #ff7e67);
}
```
JavaScript代码:
```
// 可以根据需要添加相关的JavaScript代码
```
这个示例页面使用了线性渐变的背景色、阴影效果、表单输入框动态标签等华丽的设计,同时也使用了一些简单的CSS动画和JavaScript交互效果。你可以在这个基础上进行自己的修改,添加更多的特效和交互功能。
阅读全文