Home > Blockchain >  The bottom part of The form animates
The bottom part of The form animates

Time:11-04

So I made this login in form for a practice but i ran into a problem when creating the button at a smaller screen it cases the entire form to animate a little and i dont know why i tried putting transition none on @media query I made for wider screen size and tried putting the transition none on it but it did not work i even tried putting it on the container it self but it did not work.

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

html {
    font-size: 65.5%;
    font-family: 'Times New Roman', Times, serif;
}

body {
    line-height: 1.4;
    font-size: 1.5rem;
}

.learn {
    display: grid;
    place-items: center;
    grid-template-columns: 1fr;
    height: 100vh;
}

@media(min-width:85rem) {
    .learn .bg-color-container {
        max-width: 40rem;
        width: 100%;





    }






    .bg-color-container button {
        max-width: 100%;
        width: 420px;
        padding: 2rem 0;





    }




}




    form .input__data {
        display: flex;
        flex-direction: column;
        padding: 1rem 0;
        position: relative;
        top: -2.1rem;
        width: 100%;
    }
    
    .bg-color-container {
    
        background-color: rgb(236, 244, 243);
        width: 100%;
        max-width: 400px;
        padding: 5rem 1.8rem;
        border-radius: 1.2rem;
        box-shadow: 0 8px 8px 5px rgb(0, 0, 0, 0.5);
    
    }
    
    .dec-adder h1 {
        position: relative;
        top: -3rem;
        max-width: 250px;
        font-size: 3.1rem;
    
    }
    
    input {
        padding: 1.2rem;
        margin-top: .4rem;
    
    }
    
    [type=email],
    [type=password] {
        background: #ffffff;
        border: none;
        border-radius: .5rem;
    
    
    
    }
    
    .separate-content {
        position: relative;
        top: -2.1rem;
    }
    
    .separate-content input {
        margin-right: 0.5rem;
        font-weight: bolder;
    
    
    }
    
    form button {
        max-width: 100%;
        width: 320px;
        padding: 1.5rem 0;
        border-radius: 1rem;
        border: none;
        background: #fff;
        transition: 2s ease-in;
        cursor: pointer;
    
        color: black;
    }
    
    form button:hover {
        background-color: #7c47c0;
    
    
    
        color: #fff;
    }
    
    form label {
        font-weight: bold;
    }
<section >
        

        <div >
            <h1>Sign in with your credentials</h1>
            <form action="#" method="post">
                <div >
                    <label for="Email">Email Address</label>
                    <input type="email" name="email" id="Email" autofocus required placeholder="Your Address">
                </div>
                <div >
                    <label for="lg-password">Enter Passward</label>
                    <input type="password" name="Security-Passcode" id="lg-password" required>
                </div>
                <label  for="lg-remember">
                    <input type="checkbox" name="lg-remember" id="lg-remember" required> Remember Me
                </label>
                <div><button type="submit ">Sign Up</button></div>
            </form>
        </div>

        
    </section>

CodePudding user response:

Simply remove padding: 2rem 0; from .bg-color-container button from under the media query. That padding adds a height to the button and the entire form needs to shrink or grow to accommodate that padding being added or subtracted. If you still need the padding I suggest adding a new CSS for .bg-color-container button outside of the media query and it will always be there.

Take a look here:

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

html {
    font-size: 65.5%;
    font-family: 'Times New Roman', Times, serif;
}

body {
    line-height: 1.4;
    font-size: 1.5rem;
}

.learn {
    display: grid;
    place-items: center;
    grid-template-columns: 1fr;
    height: 100vh;
}

@media(min-width:85rem) {
    .learn .bg-color-container {
        max-width: 40rem;
        width: 100%;
    }

    .bg-color-container button {
        max-width: 100%;
        width: 420px;
    }

}




    form .input__data {
        display: flex;
        flex-direction: column;
        padding: 1rem 0;
        position: relative;
        top: -2.1rem;
        width: 100%;
    }
    
    .bg-color-container {
    
        background-color: rgb(236, 244, 243);
        width: 100%;
        max-width: 400px;
        padding: 5rem 1.8rem;
        border-radius: 1.2rem;
        box-shadow: 0 8px 8px 5px rgb(0, 0, 0, 0.5);
    
    }
    
    .dec-adder h1 {
        position: relative;
        top: -3rem;
        max-width: 250px;
        font-size: 3.1rem;
    
    }
    
    input {
        padding: 1.2rem;
        margin-top: .4rem;
    
    }
    
    [type=email],
    [type=password] {
        background: #ffffff;
        border: none;
        border-radius: .5rem;
    
    
    
    }
    
    .separate-content {
        position: relative;
        top: -2.1rem;
    }
    
    .separate-content input {
        margin-right: 0.5rem;
        font-weight: bolder;
    
    
    }
    
    form button {
        max-width: 100%;
        width: 320px;
        padding: 1.5rem 0;
        border-radius: 1rem;
        border: none;
        background: #fff;
        transition: 2s ease-in;
        cursor: pointer;
    
        color: black;
    }
    
    form button:hover {
        background-color: #7c47c0;
    
    
    
        color: #fff;
    }
    
    form label {
        font-weight: bold;
    }
    
   .bg-color-container button {
        padding: 2rem 0;
    }
<section >
        

        <div >
            <h1>Sign in with your credentials</h1>
            <form action="#" method="post">
                <div >
                    <label for="Email">Email Address</label>
                    <input type="email" name="email" id="Email" autofocus required placeholder="Your Address">
                </div>
                <div >
                    <label for="lg-password">Enter Passward</label>
                    <input type="password" name="Security-Passcode" id="lg-password" required>
                </div>
                <label  for="lg-remember">
                    <input type="checkbox" name="lg-remember" id="lg-remember" required> Remember Me
                </label>
                <div><button type="submit ">Sign Up</button></div>
            </form>
        </div>

        
    </section>

But if you still want the button to grow in height as well without affecting the rest of the form, I'd suggest assigning the div containing the button a class and then give that div a fixed height. Like this:

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

html {
    font-size: 65.5%;
    font-family: 'Times New Roman', Times, serif;
}

body {
    line-height: 1.4;
    font-size: 1.5rem;
}

.learn {
    display: grid;
    place-items: center;
    grid-template-columns: 1fr;
    height: 100vh;
}

@media(min-width:85rem) {
    .learn .bg-color-container {
        max-width: 40rem;
        width: 100%;
    }

    .bg-color-container button {
        max-width: 100%;
        width: 420px;
        padding: 2rem 0;
    }

}




    form .input__data {
        display: flex;
        flex-direction: column;
        padding: 1rem 0;
        position: relative;
        top: -2.1rem;
        width: 100%;
    }
    
    .bg-color-container {
    
        background-color: rgb(236, 244, 243);
        width: 100%;
        max-width: 400px;
        padding: 5rem 1.8rem;
        border-radius: 1.2rem;
        box-shadow: 0 8px 8px 5px rgb(0, 0, 0, 0.5);
    
    }
    
    .dec-adder h1 {
        position: relative;
        top: -3rem;
        max-width: 250px;
        font-size: 3.1rem;
    
    }
    
    input {
        padding: 1.2rem;
        margin-top: .4rem;
    
    }
    
    [type=email],
    [type=password] {
        background: #ffffff;
        border: none;
        border-radius: .5rem;
    
    
    
    }
    
    .separate-content {
        position: relative;
        top: -2.1rem;
    }
    
    .separate-content input {
        margin-right: 0.5rem;
        font-weight: bolder;
    
    
    }
    
    form button {
        max-width: 100%;
        width: 320px;
        padding: 1.5rem 0;
        border-radius: 1rem;
        border: none;
        background: #fff;
        transition: 2s ease-in;
        cursor: pointer;
    
        color: black;
    }
    
    form button:hover {
        background-color: #7c47c0;
    
    
    
        color: #fff;
    }
    
    form label {
        font-weight: bold;
    }
    
    
    .btncontain {
   height: 2rem;
    }
    
 <section >
        

        <div >
            <h1>Sign in with your credentials</h1>
            <form action="#" method="post">
                <div >
                    <label for="Email">Email Address</label>
                    <input type="email" name="email" id="Email" autofocus required placeholder="Your Address">
                </div>
                <div >
                    <label for="lg-password">Enter Passward</label>
                    <input type="password" name="Security-Passcode" id="lg-password" required>
                </div>
                <label  for="lg-remember">
                    <input type="checkbox" name="lg-remember" id="lg-remember" required> Remember Me
                </label>
                <div ><button type="submit ">Sign Up</button></div>
            </form>
        </div>

        
    </section>

CodePudding user response:

Make sure to add dimensions of smaller screens in your media query (max-width: 600px for screens smaller than 600 pixels width) and then give them styling whatever you want. I hope this helps but you can attach your CSS if it doesn't work.

  • Related