Home > Blockchain >  Why my overlay container is not moving left when I click SIGN UP button?
Why my overlay container is not moving left when I click SIGN UP button?

Time:12-19

this is my codepan link:https://codepen.io/xaviour1504/pen/zYEzGLJ when I am trying to click the sign up button only the sign-in part is moving to right but the overlay-container part is not moving to left. Here is my code for

    /* move overlay to left */
    .container.right-panel-active.overlay-container {
        transform: translateX(-100%);
    }

CodePudding user response:

You are not selecting the overlay correctly.

Use:

.container.right-panel-active .overlay-container

That is, when right-panel-active class is set a child with overlay-container class is to be selected (that's what the space is for).

CodePudding user response:

Try using these values:

/* move sign in to the right */
.container.right-panel-active .sign-in-container {
    transform: translateX(-100%);
}
/* move overlay to left */
.container.right-panel-active.overlay-container {
    transform: translateX(100%);
}

See here:

const signUpButton = document.getElementById('signUp');
const signInButton = document.getElementById('signIn');
const content = document.getElementById('container');

signUpButton.addEventListener('click', () =>
    content.classList.add('right-panel-active')
);

signInButton.addEventListener('click', () =>
    content.classList.remove('right-panel-active')
);
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600&display=swap');

* {
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: rgb(238, 229, 229);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: -20px 0 50px;
    overflow: hidden;
}

h1 {
    font-weight: bolder;
    margin: 0;
}

p {
    font-size: 15px;
    font-weight: 100;
    letter-spacing: 0.5px;
    line-height: 20px;
    margin: 20px 0 30px;
}

span {
    font-size: 15px;
    line-height: 20px;
    letter-spacing: 0.5px;
    font-weight: 100;
}

a {
    color: #333;
    text-decoration: none;
    font-size: 15px;
    margin: 15px 0;
}

.container {
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
    position: relative;
    overflow: hidden;
    width: 800px;
    max-width: 100%;
    min-height: 490px;
}

.form-container form {
    background: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 0 50px;
    text-align: center;
}

.social-container {
    margin: 20px 0;
}

.social-container a {
    border: solid 2px #ddd;
    border-radius: 50%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    margin: 0 5px;
    width: 40px;
    height: 40px;
}

.form-container input {
    background: #eee;
    border: none;
    padding: 12px 15px;
    margin: 8px 0;
    width: 100%;
}

button {
    border: 1px solid orangered;
    border-radius: 20px;
    background: orangered;
    color: white;
    font-size: 15px;
    font-weight: 100;
    padding: 10px 40px;
    letter-spacing: 1px;
    transition: transform 80ms ease-in;
}

button:active {
    transform: scale(0.95);
}

button:focus {
    outline: none;
}

button.ghost {
    background: transparent;
    border-color: white;
}

.form-container {
    position: absolute;
    top: 0;
    height: 100%;
    transition: all 0.6s ease-in-out;
}

.sign-in-container {
    left: 0;
    width: 50%;
    z-index: 1;
}
.sign-up-container {
    opacity: 0;
    width: 50%;
    z-index: 1;
}
.overlay-container {
    position: absolute;
    top: 0;
    left: 50%;
    width: 50%;
    height: 100%;
    overflow: hidden;
    transition: transform 0.6s ease-in-out;
    z-index: 100;
}
.overlay {
    background: #ff416c;
    background: linear-gradient(to right, #ff4b2b, #ff416c) no-repeat 0 0 / cover;
    color: white;
    position: relative;
    left: -100%;
    height: 100%;
    width: 200%;
    transform: translateX(0);
    transition: transform 0.6s ease-in-out;
}

.overlay-panel {
    position: absolute;
    top: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0 40px;
    height: 100%;
    width: 50%;
    text-align: center;
    transform: translateX(0);
    transition: transform 0.6s ease-in-out;
}

.overlay-right {
    right: 0;
    transform: translateX(0);
}

.overlay-left {
    transform: translateX(-20%);
}

/* animation */

/* move sign in to the right */
.container.right-panel-active .sign-in-container {
    transform: translateX(-100%);
}
/* move overlay to left */
.container.right-panel-active.overlay-container {
    transform: translateX(100%);
}
<div  id="container">
            <div >
                <form action="#">
                    <h1>Create Account</h1>
                    <div >
                        <a href="#" ><i ></i></a>
                        <a href="#" ><i ></i></a>
                        <a href="#" ><i ></i></a>
                    </div>
                    <span>or use your email for registration </span>
                    <input type="text" placeholder="Name" />
                    <input type="email" placeholder="Email" />
                    <input type="Password" placeholder="Password" />
                    <button>SIGN UP</button>
                </form>
            </div>
            <div >
                <form action="#">
                    <h1>Sign in</h1>
                    <div >
                        <a href="#" ><i ></i></a>
                        <a href="#" ><i ></i></a>
                        <a href="#" ><i ></i></a>
                    </div>
                    <span>or use your account </span>
                    <input type="email" placeholder="Email" />
                    <input type="Password" placeholder="Password" />
                    <a href="#">Forgot your password?</a>
                    <button>SIGN IN</button>
                </form>
            </div>
            <div >
                <div >
                    <div >
                        <h1>Welcome Back!</h1>
                        <p>
                            To keep connected with us please login with your personal info
                        </p>
                        <button  id="signIn">SIGN IN</button>
                    </div>
                    <div >
                        <h1>Hello, Friend!</h1>
                        <p>Enter your personal details and start journey with us</p>
                        <button  id="signUp">SIGN UP</button>
                    </div>
                </div>
            </div>
        </div>

  • Related