Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8878857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:48:49+00:00 2026-06-14T19:48:49+00:00

Here is a little sample. The two div s are supposed to float to

  • 0

Here is a little sample. The two divs are supposed to float to center after clicking it, while the other one should disappear. After clicking the “x”, it should go back to status quo. This works fine for both, except that for the right div, the animation has a strange behaviour.

It is the first time I’m trying to do something with animate(), so maybe I oversee somethin obvious. As you can see after clicking the “x” on the right div, it first moves to the bottom of the page, and after that it moves to the right place (which is pretty ugly). All I do in animate() is resetting the changed values to default, like on the first div. As in the first div I change only the margin, it pretty sure has something to do with the changing of the height. How can I suppress this behaviour and let it move directly to that position?

Browser: Firefox 16.0.2
fiddle-link

test.html

<!DOCTYPE html>
<html>
    <head>

        <title>Welcome to BetManager</title>
        <meta charset="UTF-8"/>
        <link href="css/mainContent.css"    type="text/css" rel="stylesheet" />
        <link href="css/headContent.css"    type="text/css" rel="stylesheet" />
        <link href="css/welcome.css"        type="text/css" rel="stylesheet" />

        <script src="js/jquery-1.8.2.min.js"></script>
        <script src="js/welcome.js"></script>

    </head>
    <body>

        <div class="mainContainer">
            <div class="headContentContainer">

            </div>
            <div class="mainContentContainer">

                <div id="welcomeLogin" class="welcomeInnerContainer">
                    <div class="firstView" id="firstViewLogin">
                        default Image Login
                    </div>
                    <div class="afterView" id="afterViewLogin">
                        <div id="cancelLogin">
                            x
                        </div>
                    </div>
                </div>

                <div id="welcomeRegister" class="welcomeInnerContainer">
                    <div class="firstView" id="firstViewRegister">
                        default Image Register
                    </div>
                    <div class="afterView" id="afterViewRegister">
                        <div id="cancelRegister">
                            x
                        </div>
                    </div>
                </div>

            </div>
        </div>

    </body>
</html>

welcome.js

$(document).ready(function(){

    // login panel
    $("#firstViewLogin").click(function(){
        $("#welcomeRegister").hide();
        $("#welcomeLogin").animate({
            marginLeft:'35%'
        });
        $("#firstViewLogin").fadeOut(500);
        $("#afterViewLogin").delay(500).fadeIn(500);
    });

    $("#welcomeLogin").hover(function(){
            $("#welcomeLogin").addClass("welcomeInnerContainerHovered");
        },
        function(){
            $("#welcomeLogin").removeClass("welcomeInnerContainerHovered");
    });

    $("#cancelLogin").click(function(){
        $("#welcomeLogin").animate({
            marginLeft:'15%'
        });
        $("#afterViewLogin").fadeOut(500);
        $("#firstViewLogin").delay(500).fadeIn(500);
        $("#welcomeRegister").show();
    });

    // register panel
    $("#firstViewRegister").click(function(){
        $("#welcomeLogin").hide();
        $("#welcomeRegister").animate({
            marginRight:'35%',
            height:'80%',
            marginTop:'5%'
        });
        $("#firstViewRegister").fadeOut(500);
        $("#afterViewRegister").delay(500).fadeIn(500);
    });

    $("#welcomeRegister").hover(function(){
            $("#welcomeRegister").addClass("welcomeInnerContainerHovered");
        },
        function(){
            $("#welcomeRegister").removeClass("welcomeInnerContainerHovered");
    });

    $("#cancelRegister").click(function(){
        $("#welcomeRegister").animate({
            marginRight:'15%',
            height:'60%',
            marginTop:'10%'
        });
        $("#afterViewRegister").fadeOut(500);
        $("#firstViewRegister").delay(500).fadeIn(500);
        $("#welcomeLogin").show();
    });

});

welcome.css

body{
    background: #EEEEEE;
    width: 1920px;
    height: 900px;
    min-height:900px;
    margin:auto;
    font-family: Calibri;
}

.mainContainer{
    width: 80%;
    height:96%;
    min-height:96%;
    margin: auto;
    margin-top:2%;
}

.mainContentContainer{
    background: #CCCCCC;
    width: 100%;
    height:90%;
    min-height:80%;
    margin:auto;
}

.welcomeInnerContainer{
    width: 30%;
    height: 60%;
    border-radius: 5px;
    background: white;
    margin-top: 10%;
    cursor: pointer;
}

.headContentContainer{
    background: #999999;
    width:100%;
    height: 10%;
}

.welcomeInnerContainerHovered{
    width: 30%;
    height: 60%;
    background: white;
    margin-top: 10%;
    cursor: pointer;
    box-shadow: 6px 6px 6px #777777;
}

#welcomeLogin{
    float:left;
    margin-left: 15%;
}

#welcomeRegister{
    float:right;
    margin-right: 15%;
}

.afterView{
    display: none;
    cursor: default;
}

#cancelLogin{
    margin-left: 2%;
    cursor: pointer;
}

#cancelRegister{
    margin-left: 2%;
    cursor: pointer;  
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:48:50+00:00Added an answer on June 14, 2026 at 7:48 pm

    Take a look at http://jsfiddle.net/TFtMq – dbaseman

    You may first want change thing like this to use callback function (A function to call once the animation is complete). http://api.jquery.com/fadeIn/

    $("#firstViewLogin").fadeOut(500);
    $("#afterViewLogin").delay(500).fadeIn(500);
    

    to

    $('#firstViewLogin').fadeOut(500, function() {
        $("#afterViewLogin").fadeIn(500);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A little stuck here. I have a simple question I guess. Given the following
A little help here to figure out what error to run this piece of
Just a little confused here... I have a function in postgres, and when I'm
Going a little insane here. Here is the jsfiddle: http://jsfiddle.net/mersenneprimes/CvGKK/ Note business is in
I am a little perplexed here with the actions of WPF. I can change
I would need little help here. I'm trying to get the git respository from
I need a little help here please.What am trying to do is pull all
I need a little help here: I get a file from an HTML upload
Hey guys I have a little issue here. I have a panel where I
I've got a little challenge here for you all, there is the data: CREATE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.