登录、注册页面的动态切换

                                         治愈小屋


html 的部分:

<!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>滑动切换页面</title>
    <link rel="stylesheet" href="登录和注册页面切换.css">
</head>
<body>
    <div class="container">
        
        <div class="form">
            <div class="register">
                 <h1>Register</h1>
                 <input type="text" placeholder="手机号">
                 <input type="email" placeholder="邮箱">
                 <input type="password" placeholder="密码">
                 <input type="password" placeholder="确认密码">
                 <button><a href="治愈系列.html">注册</a></button>
            </div>
           <div class="login hidden">
                 <h1>Login</h1>
                 <input type="text" placeholder="手机号或邮箱">
                 <input type="text" placeholder="用户名">
                 <input type="password" placeholder="密码">
                 <button><a href="治愈系列.html">登录</a></button>
            </div> 
        </div>
            <div class="back right">
                 <h2>欢迎来到<span>治愈小屋</span></h2>
                 <p>我在人间贩卖美好风景</p>
                 <em><img src="images/QQ图片20230315172650.jpg" width="150px" height="200px"></em>
                 <a>已有帐号?</a>
                 <button id="login1">去登录</button>
            </div>
            <div class="back left">
                <h2>欢迎来到<span>治愈小屋</span></h2>
                <p>我在人间贩卖美好风景</p>
                <em><img src="images/QQ图片20230315172650.jpg" width="150px" height="200px"></em>
                <a>没有帐号?</a>
                <button id="register1">去注册</button>
        
    </div>

css的部分:

*{
   padding: 0;
   margin: 0;
   
}
body{
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: url("images/D6799F45C551901AB01E488BCD1E54D8.png") no-repeat;
    
    /* background: linear-gradient(to right,#fceaea,#fcf2e8,#dfe3e2,#becfd3); */
}
.container{
       background:rgb(255,255,255,.24);
       width: 680px;
       height: 415px;
       border-radius: 5px;
       box-shadow: 5px 5px 5px rgba(0,0,0,.1);
       position:relative;
       /* #e5b4be,#c898b0,#929dbe,#78b0ce */
}
.form{
    position: absolute;
    top: -17px;
    left: 5%;
    background:#a6bce8;
    width: 320px;
    height: 450px;
    border-radius: 5px;
    box-shadow: 2px 0 10px rgba(0,0,0,.1);
    justify-content: center;
    align-items: center;
   display: flex;
   z-index: 2;
   transition: 0.5s ease-in-out;
}
.register,
.login{
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}
.hidden{
    display: none;
    transition:0.5s;
}
h1{
    text-align: center;
    margin-bottom: 20px;
    text-transform: uppercase;
    color:#fff;
    letter-spacing: 5px;
}
input{
    background-color: transparent;
    width: 274px;
    border: none;
    outline: none;
    color:#fff;
    font-size:18px;
    text-indent:10px;
    margin:10px 0;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0, 0, 0, .3);
}
input::placeholder{
    color: #fff;
}
input:focus{
color: rgb(148, 138, 220);
border-bottom: 1px solid #fcf2e8;
}
input:focus::placeholder{
    opacity: 0;
}
.form button{
    width: 100px;
    font-size: large;
    letter-spacing: 5px;
    margin-top: 21px;
    border-radius: 5px;
    border: none;
    outline: none;
    color:#9d87ea;
    background-color:#Fff;
    padding: 5px;
}
.form a{
    text-decoration: none;
    color:#9d87ea; 
}
.form button:hover{
color: #f6f6f6;
background:linear-gradient(to right,#fceaea,#fcf2e8,#dfe3e2);
transition: background-color 0.5s ease;
}
.back{
    width: 320px;
    display:flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 200px;
    transform: translateY(-50%);
}
.back.left{
    left:-2%;
}
.back.right{
    right: -2%;
}
.back h2{
    color:#8e99af;
    font-size:25px;
    font-weight: bold;
    letter-spacing: 2px;
    text-align: center;
    margin-bottom: 4px;
}
.back span{
    color:rgb(148, 138, 220);
}
.back p{
    color:#a3aec5;
    font-size:17px;
    letter-spacing: 2px;
    text-align: center;
}
.back em{
    height: 240px;
}
.back img{
    margin-top: 20px;
}
.back a{
    font-style: italic;
    color:skyblue;
}
.back button{
    color:#9d87ea;
    background-color: #fff;
    border-radius: 10px;
    width: 90px;
    padding: 5px 3px;
    border: none;
    outline: none;
    border:1px solid #ccc;
    letter-spacing: 3px;
    font-size: 18px;
}

script的部分:

 <script>
        var login1=document.getElementById('login1');
        var register1=document.getElementById('register1');
        var form = document.querySelector('.form');
        var login=document.querySelector('.login');
        var register = document.querySelector('.register');
        login1.addEventListener('click',function(){
            form.style.transform= 'translateX(90%)';
            register.classList.add('hidden');
            login.classList.remove('hidden');
            form.style.backgroundColor='#a39fdb';
            register1.style.color='#a6bce8';
        })
        register1.addEventListener('click',function(){
            form.style.transform= 'translateX(0%)';
            login.classList.add('hidden');
            register.classList.remove('hidden');
            form.style.backgroundColor='#859ed0';
        })
    </script>

        最后的最后感谢我们自己啦啦啦啦啦!!!!!!!!

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值