用HTML和css还有js实现登录和注册。登录和注册有QQ邮箱验证,一定要可以QQ邮箱验证。QQ邮箱一定可以接到我发的验证码,是QQ邮箱自己生成的,不是我代码强行给他的。QQ邮箱可以里面看到,在QQ邮箱得到验证码。背景有轮播图
时间: 2024-05-04 14:18:47 浏览: 153
简单的登录注册页面 实现js验证
5星 · 资源好评率100%
好的,我可以为您提供一些思路和代码示例来实现这个功能。
HTML代码示例:
```
<!DOCTYPE html>
<html>
<head>
<title>Login and Register</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="slider">
<img src="image1.jpg" class="active">
<img src="image2.jpg">
<img src="image3.jpg">
</div>
<div class="form">
<ul class="tab-group">
<li class="tab active"><a href="#login">Log In</a></li>
<li class="tab"><a href="#register">Register</a></li>
</ul>
<div class="tab-content">
<div id="login">
<h1>Welcome Back!</h1>
<form action="/" method="post">
<div class="field-wrap">
<label>
Email<span class="req">*</span>
</label>
<input type="email"required autocomplete="off"/>
</div>
<div class="field-wrap">
<label>
Password<span class="req">*</span>
</label>
<input type="password"required autocomplete="off"/>
</div>
<p class="forgot"><a href="#">Forgot Password?</a></p>
<button class="button button-block">Log In</button>
</form>
</div>
<div id="register">
<h1>Sign Up for Free</h1>
<form action="/" method="post">
<div class="top-row">
<div class="field-wrap">
<label>
First Name<span class="req">*</span>
</label>
<input type="text" required autocomplete="off" />
</div>
<div class="field-wrap">
<label>
Last Name<span class="req">*</span>
</label>
<input type="text"required autocomplete="off"/>
</div>
</div>
<div class="field-wrap">
<label>
Email Address<span class="req">*</span>
</label>
<input type="email"required autocomplete="off"/>
</div>
<div class="field-wrap">
<label>
Set A Password<span class="req">*</span>
</label>
<input type="password"required autocomplete="off"/>
</div>
<div class="field-wrap">
<label>
Confirm Password<span class="req">*</span>
</label>
<input type="password"required autocomplete="off"/>
</div>
<div class="field-wrap">
<label>
QQ Email<span class="req">*</span>
</label>
<input type="email"required autocomplete="off"/>
</div>
<div class="field-wrap">
<label>
QQ Verification Code<span class="req">*</span>
</label>
<input type="text"required autocomplete="off"/>
<button class="button button-block">Get Verification Code</button>
</div>
<button type="submit" class="button button-block">Get Started</button>
</form>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
```
CSS代码示例:
```
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Helvetica Neue", sans-serif;
background: #f5f5f5;
}
.slider {
position: relative;
overflow: hidden;
margin-top: -20px;
}
.slider img {
display: none;
position: absolute;
top: 0;
left: 0;
}
.slider img.active {
display: block;
}
.form {
background: rgba(19, 35, 47, 0.9);
padding: 40px;
max-width: 600px;
margin: 40px auto;
border-radius: 4px;
box-shadow: 0 4px 10px 4px rgba(19, 35, 47, 0.3);
}
.tab-group {
list-style: none;
padding: 0;
margin: 0 0 40px 0;
position: relative;
}
.tab-group:after {
content: "";
display: table;
clear: both;
}
.tab-group li a {
display: block;
text-decoration: none;
padding: 15px;
background: rgba(160, 179, 176, 0.25);
color: #a0b3b0;
font-size: 20px;
float: left;
width: 50%;
text-align: center;
cursor: pointer;
transition: .5s ease;
}
.tab-group li a:hover {
background: #a0b3b0;
color: #fff;
}
.tab-group .active a {
background: #fff;
color: #a0b3b0;
}
.tab-content > div:last-child {
display: none;
}
.field-wrap {
position: relative;
margin-bottom: 40px;
}
.field-wrap input {
font-size: 20px;
display: block;
width: 100%;
padding: 10px;
height: 55px;
border: none;
border-radius: 4px;
background: rgba(255, 255, 255, 0.1);
color: #fff;
border: 1px solid rgba(255, 255, 255, 0.2);
box-shadow: inset 0 -10px 10px -10px rgba(255, 255, 255, 0.1);
transition: .5s ease;
}
.field-wrap input:focus {
outline: none;
background: rgba(255, 255, 255, 0.2);
box-shadow: inset 0 -10px 10px -10px rgba(255, 255, 255, 0.1);
}
.forgot {
display: inline-block;
float: right;
font-size: 12px;
text-decoration: underline;
color: #a0b3b0;
cursor: pointer;
}
.button {
border: none;
background: #a0b3b0;
color: #fff;
padding: 15px 20px;
border-radius: 4px;
width: 100%;
font-size: 20px;
cursor: pointer;
transition: .5s ease;
}
.button:hover, .button:focus {
background: #fff;
color: #a0b3b0;
}
.button-block {
display: block;
}
.top-row {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin-bottom: 20px;
}
.top-row > div {
width: 48%;
}
.hide {
display: none;
}
label {
font-weight: 600;
font-size: 12px;
color: #fff;
margin-bottom: 5px;
display: block;
}
.req {
margin: 0 2px;
color: #a0b3b0;
}
.forgot-password {
display: inline-block;
float: right;
font-size: 12px;
text-decoration: underline;
color: #a0b3b0;
cursor: pointer;
margin-top: 20px;
}
```
JavaScript代码示例:
```
const form = document.querySelector('.form');
const tabGroup = document.querySelector('.tab-group');
const tabContent = document.querySelectorAll('.tab-content > div');
const loginTab = document.querySelector('#login');
const registerTab = document.querySelector('#register');
const verificationCodeBtn = document.querySelector('.field-wrap button');
// Switch tabs
tabGroup.addEventListener('click', e => {
if (e.target.tagName === 'A') {
e.preventDefault();
const href = e.target.getAttribute('href');
tabGroup.querySelector('.active').classList.remove('active');
e.target.parentNode.classList.add('active');
tabContent.forEach(content => {
content.classList.add('hide');
if (content.getAttribute('id') === href.slice(1)) {
content.classList.remove('hide');
}
})
}
});
// Get verification code
verificationCodeBtn.addEventListener('click', e => {
e.preventDefault();
// Send verification code to QQ email
// ...
});
```
以上是示例代码,您可以根据实际需要进行修改和调整。需要注意的是,QQ邮箱验证需要使用邮件服务商提供的API进行实现,具体实现方法可以参考邮件服务商提供的文档和示例代码。
阅读全文