用html,css,JavaScript编写一个用户注册,登录功能的页面,css和JavaScript为外部文件,添加css圆角,过渡,动画属性
时间: 2023-06-10 16:06:59 浏览: 286
login_admin_html5_javascript_course9v7_css_
以下是一个简单的用户注册和登录页面的HTML代码,使用外部的CSS和JavaScript文件来添加圆角、过渡和动画属性:
```html
<!DOCTYPE html>
<html>
<head>
<title>User Registration and Login</title>
<link rel="stylesheet" type="text/css" href="styles.css">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<div class="container">
<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="form-container sign-in-container">
<form action="#">
<h1>Sign in</h1>
<input type="email" placeholder="Email">
<input type="password" placeholder="Password">
<a href="#">Forgot your password?</a>
<button>Sign In</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>
</body>
</html>
```
下面是一个简单的CSS代码,用于添加圆角、过渡和动画属性:
```css
/* CSS reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* Body styles */
body {
background: #f6f5f7;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: sans-serif;
}
/* Container styles */
.container {
background: #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 styles */
.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 styles */
.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: #ff416c;
background: -webkit-linear-gradient(to right, #ff4b2b, #ff416c);
background: linear-gradient(to right, #ff4b2b, #ff416c);
background-repeat: no-repeat;
background-size: cover;
background-position: 0 0;
color: #fff;
position: relative;
left: -100%;
height: 100%;
width: 200%;
transition: left 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-left {
transform: translateX(-20%);
}
.overlay-right {
right: 0;
transform: translateX(0);
}
/* Input styles */
input {
background: #f2f2f2;
border: none;
padding: 12px 15px;
margin: 8px 0;
width: 100%;
border-radius: 20px;
font-size: 16px;
color: #333;
}
/* Button styles */
button {
border-radius: 20px;
border: none;
background: #ff416c;
background: -webkit-linear-gradient(to right, #ff4b2b, #ff416c);
background: linear-gradient(to right, #ff4b2b, #ff416c);
color: #fff;
cursor: pointer;
font-size: 16px;
padding: 12px 0;
width: 100%;
margin: 10px 0;
transition: all 0.3s ease-in-out;
}
button:hover {
transform: scale(0.98);
}
.ghost {
background-color: transparent;
border-color: #fff;
color: #fff;
}
/* Other styles */
h1 {
font-weight: bold;
margin: 0 0 20px;
}
p {
font-size: 14px;
font-weight: 100;
line-height: 20px;
letter-spacing: 0.5px;
margin: 20px 0 30px;
}
a {
color: #333;
font-size: 14px;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
```
最后是一个简单的JavaScript代码,用于切换注册和登录表单:
```javascript
const signUpButton = document.getElementById('signUp');
const signInButton = document.getElementById('signIn');
const container = document.querySelector('.container');
signUpButton.addEventListener('click', () => {
container.classList.add('right-panel-active');
});
signInButton.addEventListener('click', () => {
container.classList.remove('right-panel-active');
});
```
阅读全文