登录注册界面

需要唯美柔和的登录注册界面的宝子们可以自行查看,内有账号验证,手机号验证,密码验证,CSS样式较多,也比较好看

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  <meta name="viewport"  content="width=device-width, initial-scale=1.0"  />
  <title>注册登录mongoDB</title>
  <link  rel="stylesheet"  href="./注册登录CSS.css"/>
</head>
<body>
  <div  class="container"  id="app">
    <div class="box" id="box">
      <div class="transtion-box">
        <div class="login-box">
          <h1>欢迎回来</h1>
          <section style="position: relative;">
            <label for="email">账号</label>
            <input  type="text"  id="loginname" maxlength="20"/>
            <span class="inputbottom"></span>
          </section>
          <section style="position: relative;">
            <label for="password">密码</label>
            <input  type="password"  id="loginpwd" maxlength="16"/> 
            <span class="inputbottom"></span>
            <span>忘记密码?</span>
          </section>
          <button  type="button"  id="login">登录</button>
          <button  type="button"  class="other">使用<span style="font-weight: 900; color: #455a81">二维码</span>扫码登录</button>
        </div>
        <div  class="reg-box"  style="display: none">
          <h1>立即注册</h1>
          <section style="position: relative;">
            <label for="username">用户名</label>
            <input  type="text"  id="regname" maxlength="16"/>
            <img  src="./img/关闭_close.png"  alt=""  class="close">
            <img  src="./img/正确_check.png"  alt=""  class="correct">
            <span class="poptip userpoptip">↑ 支持中文、字母、数字6-16位</span>
            <span class="inputbottom"></span>
          </section>
          <section style="position: relative;">
            <label for="email">手机</label>
            <input  type="text"  id="tel"  maxlength="11"/>
            <img  src="./img/关闭_close.png"  alt=""  class="telclose">
            <img  src="./img/正确_check.png"  alt=""  class="telcorrect">
            <span class="poptip telpoptip">↑ 仅支持11数字!!</span>
            <span class="inputbottom"></span>
          </section>
          <section style="position: relative;">
            <label for="password">密码</label>
            <input  type="password"  id="regpwd" maxlength="16"/>
            <img  src="./img/关闭_close.png"  alt=""  class="pwdclose">
            <img  src="./img/正确_check.png"  alt=""  class="pwdcorrect">
            <span class="poptip pwdpoptip">↑ 仅支持字母、数字、下划线5-16位</span>
            <span class="inputbottom"></span>
          </section>
          <button  type="button"  id="reg">注册</button>
          <button  type="button"  class="other">使用<span style="font-weight: 900; color: #455a81">二维码</span>扫码注册</button>
        </div>
      </div>
      <div class="transferToReg">
        <h1 class="title">还未注册?</h1>
        <span class="subTitle">立即注册,给你发100红包!</span>
        <button  type="button"  id="transfetBtn">注册</button>
      </div>
    </div>
  </div>

</body>
<script>
  let transfer = document.getElementById('transfetBtn');
  transfer.addEventListener('click', function () {
    let login = document.querySelector('.login-box');
    let reg = document.querySelector('.reg-box');
    let total = document.querySelector('.transtion-box');
    let target = document.querySelector('.transferToReg');
    let title = document.querySelector('.title');
    let subTitle = document.querySelector('.subTitle');
    transfer.innerText === '注册' ?
      (() => {
        target.style = `background: linear-gradient(to bottom right,#365269 0%,#3e78a8 50%,#6daecf 100%);left:0px;`
        total.style.left = 260 + 'px';
        transfer.innerText = '登录';
        title.innerText = '已有帐号?';
        subTitle.innerText = '有帐号就登录吧,不用注册了!';
        setTimeout(() => {
          login.style.display = 'none';
          reg.style.display = 'flex';
        }, 300);
      })() :
      (() => {
        target.style = `background: linear-gradient(to bottom right,#6daecf 0%,#3e78a8 50%,#365269 100%);left:640px;`
        total.style.left = 0;
        transfer.innerText = '注册';
        title.innerText = '还未注册?';
        subTitle.innerText = '立即注册,给你发100红包!';
        setTimeout(() => {
          login.style.display = 'flex';
          reg.style.display = 'none';
        }, 300);
      })();
  });



  //注册账号输入框 失焦事件
  let regname = document.querySelector("#regname")
  let regtel = document.querySelector("#tel")
  let regpwd = document.querySelector("#regpwd")
  let oclose = document.querySelector(".close")
  let correct = document.querySelector(".correct")
  let user_poptip = document.querySelector(".userpoptip")
  let tel_poptip = document.querySelector(".telpoptip")
  let pwd_poptip = document.querySelector(".pwdpoptip")
  let fa = 0
  regname.addEventListener("focus",()=>{
    user_poptip.style.display = "block"
  })
  regtel.addEventListener("focus",()=>{
    tel_poptip.style.display = "block"
  })
  regpwd.addEventListener("focus",()=>{
    pwd_poptip.style.display = "block"
  })
  //  注册账号 失焦验证事件
  regname.addEventListener("blur", function () {
    let name = this.value
    user_poptip.style.display = "none"
    doAjax(
          "get", 
          "http://localhost:8888/check",
          { "name": name},
          function (data) {
            // console.log('输出 xhr.responseText check为: ',data)
            if (data == "true") {
                oclose.style.display = "block"
                correct.style.display = "none"
              } else if (data == "false") {
                oclose.style.display = "none"
                correct.style.display = "block"
              }
              if (!(/\S/.test(name))) {
                oclose.style.display = "none"
                correct.style.display = "none"
              }
          }
      )
  })
  
/* 手机号 check 失焦事件 */
  let telclose = document.querySelector(".telclose")
  let telcorrect = document.querySelector(".telcorrect")
  regtel.addEventListener("blur",function(){
    let reg = /\d{11}/
    tel_poptip.style.display = "none"
    console.log(reg.test(regtel.value))
    if(reg.test(regtel.value)){
      telclose.style.display = "none"
      telcorrect.style.display = "block"
    }
    else{
      telclose.style.display = "block"
      telcorrect.style.display = "none"
    }
    if(!(/\S/.test(regtel.value))){
      telclose.style.display = "none"
      telcorrect.style.display = "none"
    }
  })
/* 密码 check 失焦事件 */
  let pwdclose = document.querySelector(".pwdclose")
  let pwdcorrect = document.querySelector(".pwdcorrect")
  regpwd.addEventListener("blur",function(){
    let reg = /^\w{5,16}/
    pwd_poptip.style.display = "none"
    if(reg.test(regpwd.value)){
      pwdclose.style.display = "none"
      pwdcorrect.style.display = "block"
    }
    else{
      pwdclose.style.display = "block"
      pwdcorrect.style.display = "none"
    }
    if(!(/\S/.test(regpwd.value))){
      pwdclose.style.display = "none"
      pwdcorrect.style.display = "none"
    }
  })

//复制粘贴
</html>

CSS样式

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  body {
    width: 100%;
    height: 100%;
  }
  .container {
    width: 100%;
    height: 100vh;
    background: url(./img/2.jpg);
    background-size: 100% 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .container .box {
    width: 900px;
    height: 550px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    position: relative;
  }
  .homepage{
    height: 40px;width: 100%;
    padding: 0 20px;
    font-size: 20px;
    line-height: 40px;
    background-color: #365269;
  }
  .homepage span{
    display: block;
    float: right;
    padding: 0 5px;
    cursor: pointer;
  }
  .homepage span:nth-child(2){
    color: #52a5f5;
  }
  .homepage img{display:block;width: 30px;height: 30px;float: left;margin-top: 5px;margin-right: 5px;}
  #home{font-size: 50px;}
  .container .box .transtion-box {
    position: absolute;
    left: 0;
    transition: 0.5s all ease-in-out;
  }
  .container .box .transtion-box .login-box,
  .reg-box {
    width: 640px;
    height: 100%;
    display: flex;
    flex-flow: column nowrap;
    align-items: center;
    padding: 50px 30px;
  }
  
  .container .box .transtion-box h1 {
    margin-bottom: 35px;
    color: #84bad4;
    text-shadow:-3px -3px 30px #84bad4,3px 3px 10px black;

  }
  .container .box .transtion-box section {
    display: flex;
    flex-flow: inherit;
    align-items: inherit;
    width: 100%;
    margin-bottom: 30px;
  }
  .container .box .transtion-box section label {
    font-size: 16px;
    color: #fff;
    text-transform: uppercase;
    margin-bottom: 8px;
  }
  .container .box .transtion-box section input {
    width: 50%;
    outline: 0;
    border: none;
    font-size: 18px;
    color: #efb3d0;
    text-align: center;
    padding: 4px 10px;
    border-bottom: 1px solid rgb(255, 255, 255);
    background: transparent;
  }
  input:-webkit-autofill {
    /*自动填入文本颜色*/
    -webkit-text-fill-color: #efb3d0;
    /*自动填入光标颜色*/
    caret-color: #efb3d0;
    /*背景透明;原理:动画由透明变有背景色;参数:背景色属性、动画时间、动画速度曲线、延迟时间*/
    transition: background-color 0s linear 3600s;
  }
  .container .box .transtion-box section span {
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    margin-top: 18px;
  }
  .container .box .transtion-box button {
    width: 50%;
    padding: 6px 0;
    text-align: center;
    border: 3px solid #5ea1ce;
    border-radius: 20px;
    background: #5ea1ce;
    color: #fff;
    opacity: .85;
    font-size: 17px;
    letter-spacing: 6px;
    text-indent: 6px;
    margin-bottom: 15px;
    cursor: pointer;
  }
  .container .box .transtion-box .other {
    border: 3px solid #84bad4;
    background: #84bad4;
    color: rgb(124, 145, 184);
    font-weight: 600;
  }
  .container .box .transferToReg {
    width: 260px;
    height: 100%;
    background: linear-gradient(
      to bottom right,
      #6daecf 0%,
      #3e78a8 50%,
      #365269 100%
    );
    opacity: .8;
    border-radius: 4px;
    position: absolute;
    left: 640px;
    top: 0;
    display: flex;
    flex-flow: column nowrap;
    align-items: center;
    padding: 50px 0;
    color: white;
    transition: all 1s ease-in-out;
  }
  .container .box .transferToReg .title {
    margin-bottom: 10px;
    transition: all 0.3s ease-in-out;
  }
  .close{
    position: absolute;
    right: 140px;
    top: 30px;
    width: 25px;
    display: none; 
  }
  .correct{
    position: absolute;
    right: 140px;
    top: 30px;
    width: 25px;
    display: none;
  }
  .telclose{
    position: absolute;
    right: 140px;
    top: 30px;
    width: 25px;
    display: none; 
  }
  .telcorrect{
    position: absolute;
    right: 140px;
    top: 30px;
    width: 25px;
    display: none;
  }
  .poptip {
    display: none;
    text-align: center;
    width: 256px;
    font-size: 13px;
    padding: 2px;
    background: rgba(0, 0, 0, 0.4);
    position: absolute;
    top: 43px;
    margin-left: -3px;
    margin-top: 3px;
    border-radius: 5px;
    filter: drop-shadow(0 0 1px rgba(0, 0, 0, .23456));
    transform-origin: 15px -6px;
    border: 1px solid #4182b9;
  }
  .pwdclose{
    position: absolute;
    right: 140px;
    top: 30px;
    width: 25px;
    display: none; 
  }
  .pwdcorrect{
    position: absolute;
    right: 140px;
    top: 30px;
    width: 25px;
    display: none;
  }
  button{
    outline: none;
  }
  input:focus ~ .inputbottom {
    transform: scaleX(1);
  }
  .inputbottom{
    position: absolute;
    top: 39px;
    width: 290px;
    height: 2px;
    background: linear-gradient(90deg, rgb(27, 17, 233) 0%, rgb(233, 23, 23) 50%, rgb(47, 37, 243) 100%);
    transform-origin:center;
    transform: scaleX(0);
    transition: transform .6s ease;
  }
  .container .box .transferToReg button {
    margin-top: 260px;
    width: 50%;
    padding: 8px 0;
    border-radius: 14px;
    letter-spacing: 10px;
    text-indent: 10px;
    font-size: 18px;
    color: #fff;
    border: 3px solid #fff;
    background: transparent;
    font-weight: 700;
    cursor: pointer;
    outline: none;
  }
  .container .box .transferToReg button:hover {
    border: 3px solid #3e81bb;
  }
  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值