写个登录注册界面
时间: 2023-06-30 14:14:10 浏览: 39
好的,我可以给您提供一个简单的登录注册界面的代码示例:
HTML代码:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login/Register</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="form-container sign-in-container">
<form action="#">
<h1>Sign in</h1>
<input type="email" placeholder="Email" />
<input type="password" placeholder="Password" />
<button>Sign In</button>
</form>
</div>
<div class="form-container sign-up-container">
<form action="#">
<h1>Create Account</h1>
<input type="text" placeholder="Name" />
<input type="email" placeholder="Email" />
<input type="password" placeholder="Password" />
<button>Sign Up</button>
</form>
</div>
<div class="overlay-container">
<div class="overlay">
<div class="overlay-panel overlay-left">
<h1>Welcome Back!</h1>
<p>To keep connected with us please login with your personal info</p>
<button class="ghost" id="signIn">Sign In</button>
</div>
<div class="overlay-panel overlay-right">
<h1>Hello, Friend!</h1>
<p>Enter your personal details and start journey with us</p>
<button class="ghost" id="signUp">Sign Up</button>
</div>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
```
CSS代码:
```css
* {
box-sizing: border-box;
}
body {
background-color: #f6f5f7;
font-family: 'Open Sans', sans-serif;
height: 100vh;
}
.container {
background-color: #fff;
border-radius: 10px;
box-shadow: 0 14px 28px rgba(0,0,0,0.25),
0 10px 10px rgba(0,0,0,0.22);
position: relative;
overflow: hidden;
width: 100%;
max-width: 1000px;
min-height: 600px;
}
.form-container {
position: absolute;
top: 0;
height: 100%;
transition: all 0.6s ease-in-out;
}
.sign-in-container {
left: 0;
width: 50%;
z-index: 2;
}
.sign-up-container {
left: 0;
width: 50%;
opacity: 0;
z-index: 1;
}
.overlay-container {
position: absolute;
top: 0;
left: 50%;
width: 50%;
height: 100%;
overflow: hidden;
transition: transform 0.6s ease-in-out;
z-index: 100;
}
.overlay {
background: linear-gradient(to right, #FF416C, #FF4B2B);
background-repeat: no-repeat;
background-size: cover;
background-position: 0 0;
color: #fff;
position: relative;
left: -100%;
height: 100%;
width: 200%;
transform: translateX(0);
transition: transform 0.6s ease-in-out;
}
.overlay-panel {
position: absolute;
top: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 0 40px;
height: 100%;
width: 50%;
text-align: center;
transform: translateX(0);
transition: transform 0.6s ease-in-out;
}
.overlay-right {
right: 0;
transform: translateX(0);
}
.overlay-left {
transform: translateX(-20%);
}
.overlay h1 {
font-weight: 600;
line-height: 1.2;
font-size: 2.5rem;
color: #fff;
}
.overlay p {
font-size: 1.2rem;
font-weight: 500;
color: #fff;
line-height: 1.5;
margin: 20px 0;
}
.overlay button {
border-radius: 20px;
border: 1px solid #fff;
background-color: transparent;
color: #fff;
font-size: 1.2rem;
font-weight: 600;
padding: 12px 30px;
margin: 10px 0;
cursor: pointer;
}
.overlay button.ghost {
background-color: #fff;
color: #FF416C;
}
.form-container.sign-up-container.show {
opacity: 1;
z-index: 2;
}
.form-container.sign-in-container.hide {
opacity: 0;
z-index: 1;
}
.overlay-container.move {
transform: translateX(-100%);
}
footer {
text-align: center;
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
line-height: 60px;
background-color: rgba(0,0,0,0.6);
}
```
JavaScript代码:
```js
const signUpButton = document.getElementById('signUp');
const signInButton = document.getElementById('signIn');
const container = document.getElementById('container');
signUpButton.addEventListener('click', () => {
container.classList.add('show');
});
signInButton.addEventListener('click', () => {
container.classList.remove('show');
});
```
这是一个简单的登录注册界面的代码示例,可以通过点击按钮来切换登录和注册的表单。您可以根据您的需求进行修改和扩展。