注册登入页面左右滑动

html

<body style="position: relative;">
    <div class="load" style="position: absolute;display: none;">
        <div class="box">
            <span class="iconfont icon-jiazai"></span>
            <p>login...</p>
        </div>
    </div>
    <div class="header cleafix">
        <div class="title">
            <span></span>
            <p>欢迎使用鼎鑫出租房管理平台</p>
        </div>
        <nav>
            <ul>
                <li>回首页</li>
                <li>帮助</li>
                <li>关于</li>
            </ul>
        </nav>
    </div>
    <main>
        <div class="box">

            <div class="top">
                <span></span>
            </div>
            <div class="bttom">
                <div class="left">
                    <div class="login-box" style="display: none;">
                        <h3>已有账号?</h3>
                        <p>有账号就登录吧,好久不见</p>
                        <button>登录</button>
                    </div>
                    <div class="enter-box">

                        <h3>还未注册?</h3>
                        <p>立即注册发现大机会</p>
                        <button>注册</button>
                    </div>

                </div>
                <div class="form-box">
                    <!-- 登录的from隐藏起来 -->
                    <div class="form-login">
                        <h1>用户登录</h1>
                        <p>UserLogin</p>
                        <div>
                            <div class="input-box"><span class="iconfont icon-yonghu"></span>
                                <input type="text" name="name">

                            </div>
                            <p class="nameError" style="width: 350px;">账号不能为空</p>
                            <div class="input-box"><span class="iconfont icon-mima"></span>
                                <input type="password" name="paw" id="paw">
                            </div>
                            <p class="pawError">密码不能为空</p>
                            <button onclick="login()">登录</button>
                            <p>忘记密码?</p>
                        </div>

                    </div>
                    <div class="from-enter" style="display: none;">
                        <h1>用户注册</h1>
                        <p>UserEnter</p>
                        <div class="box">
                            <div class="input-box">
                                <span class="iconfont icon-yonghu"
                                    style=" width: 50px;font-size: 24px;color: #e0622c;"></span>
                                <input type="text" name="name">
                            </div>


                            <div class="input-box">
                                <span class="iconfont icon-mima"
                                    style=" width: 50px;font-size: 24px;color: #e0622c;"></span>
                                <input type="text" name="paw">
                            </div>
                            <div class="input-box All">
                                <span class="bumen">
                                    部门:
                                    <select name="selectList">


                                    </select>
                                </span>

                                <span class="js">角色:
                                    <select name="selectList">

                                    </select></span>
                            </div>
                            <p id="ts" style="display: none;">账号是4 - 8个字母数字组成,字母开头</p>
                            <p class="error" style="display: none;">密码或账号错误</p>
                            <button onclick="onEnter()">注册</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </main>

</body>

cs

body {
  position: relative;
  margin: 0;
  padding: 0;
  width: 100%;
  min-width: 1250px;
  background-image: url('/images/cloud.png');
  background-repeat: no-repeat;
  background-color: #e58535;
}
body p,
body h1 {
  margin: 0;
  padding: 0;
}
body ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
body .cleafix::after,
body .cleafix::before {
  content: '';
  display: table;
  clear: both;
}
body .load {
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
  position: relative;
}
body .load > .box {
  width: 120px;
  height: 120px;
  background-color: #4c4b4b;
  border-radius: 10px;
  color: white;
  text-align: center;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
}
body .load > .box > span {
  width: 40px;
  height: 40px;
  font-size: 40px;
  animation: tein 3s infinite;
  display: block;
  margin: auto;
  position: absolute;
  left: 0;
  right: 0;
  top: 20px;
}
@keyframes tein {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
body .load > .box > p {
  position: absolute;
  font-size: 20px;
  left: 0;
  right: 0;
  top: 60px;
}
body .header {
  line-height: 64px;
  background-color: rgba(0, 0, 0, 0.2);
  color: white;
  font-weight: bolder;
}
body .header .title {
  float: left;
}
body .header nav {
  float: right;
}
body .header nav > ul > li {
  display: inline-block;
  padding-right: 25px;
}
body main {
  height: calc(100vh - 100px);
  width: 100%;
  display: grid;
  place-items: center;
  background-image: url('/images/loginbg4.png');
  background-repeat: no-repeat;
  background-size: containE;
}
body main > .box > .top {
  width: 300px;
  height: 70px;
  margin: auto;
  text-align: center;
  margin-bottom: 20px;
  background-image: url('/images/logo.png');
  background-repeat: no-repeat;
}
body main > .box > .bttom {
  height: 380px;
  width: 750px;
  box-shadow: 2px 2px 10px black;
  background-color: white;
  position: relative;
}
body main > .box > .bttom .left {
  width: 300px;
  height: 100%;
  background-image: linear-gradient(120deg, #f6d365 0%, #fda085 100%);
  background-repeat: no-repeat;
  background-size: cover;
  float: left;
  position: absolute;
  text-align: center;
  color: white;
}
body main > .box > .bttom .left > .login-box {
  position: relative;
}
body main > .box > .bttom .left > .login-box > button {
  width: 80px;
  height: 40px;
  position: absolute;
  top: 200px;
  left: 0;
  right: 0;
  margin: auto;
  border: 0;
  border-radius: 5px;
  color: white;
  background-color: rgba(229, 133, 53, 0.3);
}
body main > .box > .bttom .left > .enter-box {
  position: relative;
}
body main > .box > .bttom .left > .enter-box > button {
  width: 80px;
  height: 40px;
  position: absolute;
  top: 200px;
  left: 0;
  right: 0;
  margin: auto;
  border: 0;
  border-radius: 5px;
  color: white;
  background-color: rgba(229, 133, 53, 0.3);
}
body main > .box > .bttom .form-box {
  position: absolute;
  left: 300px;
  float: left;
  margin-left: 50px;
}
body main > .box > .bttom .form-box h1 {
  padding: 30px 0;
  display: inline-block;
  color: #e58535;
}
body main > .box > .bttom .form-box p {
  font-size: 18px;
  color: grey;
  display: inline-block;
}
body main > .box > .bttom .form-box .form-login > div {
  position: relative;
}
body main > .box > .bttom .form-box .form-login > div > p:nth-child(2) {
  color: red;
  position: absolute;
  top: 50px;
  display: none;
}
body main > .box > .bttom .form-box .form-login > div > p:nth-child(4) {
  color: red;
  position: absolute;
  top: 120px;
  display: none;
}
body main > .box > .bttom .form-box .form-login > div > div,
body main > .box > .bttom .form-box .form-login > div > button {
  margin-bottom: 33px;
}
body main > .box > .bttom .form-box .form-login > div > div {
  border: 1px #e58535 solid;
  background-color: #faf2e5;
}
body main > .box > .bttom .form-box .form-login > div > div > span {
  width: 50px;
  font-size: 24px;
  color: #e0622c;
}
body main > .box > .bttom .form-box .form-login > div > div > input {
  width: 250px;
  height: 40px;
  border: 0;
  background-color: #faf2e5;
  outline: none;
}
body main > .box > .bttom .form-box .form-login > div > button {
  width: 90px;
  height: 40px;
  border-radius: 3px;
  border: 0;
  background-color: #e0622c;
  color: white;
}
body main > .box > .bttom .form-box .from-enter > .box {
  width: 400px;
  position: relative;
}
body main > .box > .bttom .form-box .from-enter > .box #ts {
  position: absolute;
  top: 45px;
  width: 340px;
  height: 40px;
  color: red;
}
body main > .box > .bttom .form-box .from-enter > .box .input-box {
  margin-bottom: 30px;
}
body main > .box > .bttom .form-box .from-enter > .box .input-box:nth-child(1),
body main > .box > .bttom .form-box .from-enter > .box .input-box:nth-child(2) {
  border: 1px #e58535 solid;
  background-color: #faf2e5;
  display: inline-block;
}
body main > .box > .bttom .form-box .from-enter > .box .input-box input[type='text'] {
  width: 250px;
  height: 40px;
  border: 0;
  background-color: #faf2e5;
  outline: none;
}
body main > .box > .bttom .form-box .from-enter > .box .input-box .error {
  position: absolute;
  top: 125px;
  left: -50px;
  color: red;
  font-size: 14px;
  border-radius: 2px;
  padding: 2px;
  display: none;
}
body main > .box > .bttom .form-box .from-enter > .box .sectionAll > span,
body main > .box > .bttom .form-box .from-enter > .box .roleAll > span {
  font-size: 12px;
}
body main > .box > .bttom .form-box .from-enter > .box > button {
  width: 90px;
  height: 40px;
  margin: auto;
  border-radius: 3px;
  border: 0;
  background-color: #e0622c;
  color: white;
}
body main > .box > .bttom .form-box .from-enter > .box > p {
  position: absolute;
  top: 115px;
  left: 0;
  color: red;
  padding: 2px;
  border-radius: 1px;
}
/*# sourceMappingURL=./login.css.map */

js

 $('.login-box>button').click(function () {
        $('.left').animate({
            left: '0'
        }, function () {
            $('.form-login').toggle();
            $('.from-enter').toggle();
            $('.login-box').toggle();
            $('.enter-box').toggle();

        })
        $('.form-box').animate({
            left: '300px'
        });
    })
    $('.enter-box>button').click(function (e) {
        $('.left').animate({
            left: '450px'
        }, function () {
            $('.form-login').toggle();
            $('.from-enter').toggle();
            $('.login-box').toggle();
            $('.enter-box').toggle();

        })
        $('.form-box').animate({
            left: '0'
        });
        // 
    });

实现登录注册页面左右滑动,可以使用CSS3的transform属性和transition属性来实现。具体步骤如下: 1. 将登录和注册两个模块放在一个父容器中,设置父容器的宽度为两个模块的宽度之和,同时设置overflow-x: hidden,这样就可以隐藏掉父容器的水平滚动条。 2. 为父容器设置display: flex 和 flex-wrap: nowrap,使其实现横向布局。 3. 为登录和注册两个模块设置宽度和左浮动,使其排列在父容器的一行上。 4. 通过CSS3的transform属性和transition属性来实现左右滑动效果。当点击切换按钮时,通过给父容器设置transform: translateX(-100%)或transform: translateX(0),实现左右滑动的效果。 下面是一个简单的示例代码: ``` <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>登录注册页面</title> <style> .container { width: 200%; overflow-x: hidden; display: flex; flex-wrap: nowrap; transition: transform 0.5s; } .login, .register { width: 50%; float: left; } .btn { cursor: pointer; } .switch { text-align: center; } .switch label { margin-right: 20px; cursor: pointer; } #login:checked ~ .container { transform: translateX(0); } #register:checked ~ .container { transform: translateX(-100%); } </style> </head> <body> <div class="switch"> <input type="radio" name="switch" id="login" checked> <label for="login">登录</label> <input type="radio" name="switch" id="register"> <label for="register">注册</label> </div> <div class="container"> <div class="login"> <h2>登录</h2> <form> <input type="text" placeholder="用户名"> <input type="password" placeholder="密码"> <button>登录</button> </form> </div> <div class="register"> <h2>注册</h2> <form> <input type="text" placeholder="用户名"> <input type="password" placeholder="密码"> <input type="password" placeholder="确认密码"> <button>注册</button> </form> </div> </div> <script> const loginRadio = document.getElementById('login'); const registerRadio = document.getElementById('register'); const container = document.querySelector('.container'); loginRadio.addEventListener('click', () => { container.style.transform = 'translateX(0)'; }); registerRadio.addEventListener('click', () => { container.style.transform = 'translateX(-100%)'; }); </script> </body> </html> ``` 上面的代码实现了一个简单的登录注册页面左右滑动效果,当点击登录或注册按钮时,通过JavaScript代码切换父容器的transform属性,实现左右滑动效果。你可以根据自己的需求进行修改和扩展。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值