登录注册界面

JS泡泡动效,登录注册界面动态背景效果

登录注册界面
登录注册界面

代码效果:

WELCOME

JOIN US!

登录注册界面

已有有账号?去登录

html代码:

<div class="box">
        <div class="pre-box">
            <h1>WELCOME</h1>
            <p>JOIN US!</p>
            <div class="img-box">
                <img src="https://chimengblog.com/wpimg.php" >
            </div>
        </div>
        <div class="register-form">
            <div class="title-box">
                <h1>注册</h1>
            </div>
            <div class="input-box">
                <input type="text" placeholder="用户名">
                <input type="password" placeholder="密码">
                <input type="password" placeholder="确认密码">
            </div>
            <div class="btn-box">
                <button>注册</button>
                <p onclick="mySwitch()">已有有账号?去登录</p>
            </div>
        </div>
        <div class="login-form">
            <div class="title-box">
                <h1>登录</h1>
            </div>
            <div class="input-box">
                <input type="text" placeholder="用户名">
                <input type="password" placeholder="密码">
            </div>
            <div class="btn-box">
                <button>登录</button>
                <p onclick="mySwitch()">没有账号?去注册</p>
            </div>
        </div>
    </div>

CSS代码:

*{
    padding: o;
    margin: 0;
    box-sizing: border-box;
}

input{
    outline: none;
}

html,
body{
    height: 100%;
}

body{
    position: relative;
    overflow-x: hidden;
    display: flex;
    background: linear-gradient(to right, rgb(247, 209, 215), rgb(191, 227, 241));
}

span{
    position: absolute;
    bottom: 0;
    background: radial-gradient(circle at 72% 28%, #fff 3px, #ff7edf 8%, #5b5b5b, #aad7f9 100%);
    box-shadow: inset 0 0 6px #fff,
                inset 3px 0 6px #eaf5fc,
                inset 2px -2px 10px #efcde6,
                inset 0 0 60px #f9f6de,
                0 0 20px #fff;
    border-radius: 50%;
    z-index: 0;
    animation: mymove 4s linear infinite;
}

@keyframes mymove {
    0%{
        transform: translateY(0%);
        opacity: 1;
    }
    50%{
        transform: translate(10%,-1000%);
    }
    75%{
        transform: translate(-20%,-1200%);
    }
    99%{
        opacity: .9;
    }
    100%{
        transform: translateY(-1800%) scale(1.5);
        opacity: 0;
    }
}

.box{
    width: 1050px;
    height: 600px;
    display: flex;
    position: relative;
    z-index: 2;
    /* background-color: #fff; */
    margin: auto;
    border-radius: 8px;
    border: 1px solid rgb(255, 255, 255, .6);
    box-shadow: 4px 4px 3px rgb(0, 0, 0, .1);
}

.pre-box{
    width: calc(1050px /2);
    height: 100%;
    left: 0;
    top: 0;
    position: absolute;
    border-radius: 4px;
    background-color: #edd4dc;
    box-shadow: 4px 4px 3px rgb(0, 0, 0, .1);
    transition: 0.5s ease-in-out;
}

.pre-box h1{
    margin-top: 150px;
    text-align: center;
    color: white;
    letter-spacing: 5px;
    text-shadow: 4px 4px 3px rgb(0, 0, 0, .1);
}

.pre-box p{
    height: 30px;
    line-height: 30px;
    text-align: center;
    color: white;
    margin: 20px 0;
    font-weight: bold;
    text-shadow: 4px 4px 3px rgb(0, 0, 0, .1);
}

.img-box{
    width: 200px;
    height: 200px;
    margin: 20px auto;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 4px 4px 3px rgb(0, 0, 0, .1);
}

.img-box img{
    width: 100%;
    transition: 0.5s;
}

.login-form,
.register-form{
    flex: 1;
    height: 100%;
}

.title-box{
    height: 300px;
    line-height: 500px;
}

.title-box h1{
    text-align: center;
    color: white;
    letter-spacing: 5px;
    text-shadow: 4px 4px 3px rgb(0, 0, 0, .1);
}
.input-box{
    display: flex;
    flex-direction: column;
    align-items: center;
}
input{
    width: 60%;
    height: 40px;
    margin-bottom: 20px;
    text-indent: 4px;
    border: 1px solid #b0cfe9;
    border-radius: 4px;
}

input:focus{
    color: #b0cfe9;
}

input:focus::placeholder{
    opacity: 0;
}

.btn-box{
    display: flex;
    justify-content: center;
}

button{
    width: 100px;
    height: 30px;
    margin: 0 7px;
    line-height: 30px;
    border-radius: 4px;
    border: none;
    background-color: #69b3f0;
    color: #fff;
}

button:hover{
    cursor: pointer;
    opacity: .8;
}
.btn-box p{
    height: 30px;
    line-height: 30px;
    font-size: 14px;
    color: white;
}

.btn-box p:hover{
    cursor: pointer;
    border-bottom: 1px solid white;
}

JS代码:

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
        let flag=true
        const mySwitch=()=>{
            if(flag){
                $(".pre-box").css("transform","translateX(100%)")
                $(".pre-box").css("background-color","#c9e0ed")
                $("img").attr("src","https://mscar.oss-cn-chengdu.aliyuncs.com/-329db57fe5070299.png")
            }else{
                $(".pre-box").css("transform","translateX(0%)")
                $(".pre-box").css("background-color","#edd4dc")
                $("img").attr("src","	https://mscar.oss-cn-chengdu.aliyuncs.com/2022/07/20220710163814306.jpg")
            }
            flag=!flag
        }
    </script>
    <script>
        const buleCreate=()=>{
            const body = document.body
        const buble = document.createElement('span')
        let r = Math.random()*5 + 25 
        buble.style.width=r+'px'
        buble.style.height=r+'px'
        buble.style.left=Math.random()*innerWidth+'px'
        body.append(buble)
        setTimeout(()=>{
            buble.remove()
        },4000)
        }
        setInterval(() => {
            buleCreate()
        }, 200);
    </script>
© 版权声明
THE END
喜欢就支持一下吧
点赞64赞赏 分享
评论 共5条

请登录后发表评论