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

  • SEARCH
  • Home
  • 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 3787176
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:48:00+00:00 2026-05-19T11:48:00+00:00

I have a div that I am trying to swap out for another div

  • 0

I have a div that I am trying to swap out for another div with a clip effect. However, when I do this in Firefox it snaps the content left while the animation is happening and then returns it to the center upon completion.

It works as expected in IE6 (gasp! still the standard at my work, campaigning to update), but not in firefox.

What am I doing wrong?

Javascript:

<script type="text/javascript">
        $(function(){
            $("#editEmpInfo").click(function(){
              $("#selectedEmployee").hide("clip", { direction: "vertical" }, 500, function() {
                $("#editSelectedEmployee").show("clip", { direction: "vertical" }, 500);    
              });
            });

            $("#saveEmpInfo").click(function(){
              $("#editSelectedEmployee").hide("clip", { direction: "vertical" }, 500, function() {
                $("#selectedEmployee").show("clip", { direction: "vertical" }, 500);    
              });
            });

        });
    </script>

HTML:

<div class="container">
<div id="selectedEmployee" class="container400">
    <div class="currentEmp">
        <div class="currentEmpName">
            Last, First <br />
            <span class="empWorkUnit">Work Unit</span>
        </div>

        <div id="editEmpInfo"><a title="Edit" href="#"></a></div>
                <div class="currentEmpInfo">
            <div>Ext: </div>
            <div>Cell: </div>
            <div>Home: </div>
            <div>Pager: </div>
            <div>Other: </div>

            <div>Notes: </div>
        </div>
    </div>
</div>

<div id="editSelectedEmployee" class="container400 hidden">
    <div class="currentEmp">
        <div class="currentEmpName">
            Last, First <br />

            <span class="empWorkUnit">Work Unit</span>
        </div>
        <div id="saveEmpInfo"><a title="Save" href="#"></a></div>
        <div class="currentEmpInfo">
            <div>Ext: </div>
            <div>Cell: </div>
            <div>Home: </div>

            <div>Pager: </div>
            <div>Other: </div>
            <div>Notes: </div>
        </div>
    </div>
</div>
</div>

CSS:

body {
    font-family: "Lucida Sans Unicode","Lucida Grande",Sans-Serif;
    font-size: 12px;
}

.container {
    margin-left: auto;
    margin-right: auto;
    text-align: center;    
}

.container400 {
    width: 400px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
}

.hidden {
    display: none;
}

.currentEmp {
    border: solid 1px #CCCCCC;
    display: block;
    padding: 10px;
}

#selectedEmployee {
    background: #EEEEEE;
}

#editSelectedEmployee {
    background: #E8EDFF;
}

.currentEmpName {
    font-size: 18px;
    color: #0077D4;
    float: left;
}

.currentEmpName .empWorkUnit {
    font-style: italic;
    font-size: 14px;
    font-weight: normal;
    color: #000000;
}

#editEmpInfo a{
    display: block;
    background: url("../images/Edit.png") no-repeat;
    width: 32px;
    height: 32px;
    margin: 5px;
    float: right;
}

#upOneLevel a{
    display: block;
    background: url("../images/Up.png") no-repeat;
    width: 32px;
    height: 32px;
    margin: 5px;
    float: right;
}

#saveEmpInfo a{
    display: block;
    background: url("../images/Save.png") no-repeat;
    width: 32px;
    height: 32px;
    margin: 5px;
    float: right;
}

.currentEmpInfo {
    clear: both;
}

#callSheet {
    border-collapse: collapse;
    font-family: "Lucida Sans Unicode","Lucida Grande",Sans-Serif;
    font-size: 12px;
    margin: 20px;
    text-align: left;
    min-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

#callSheet th {
  background: none repeat scroll 0 0 #B9C9FE;
  color: #003399;
  font-size: 13px;
  font-weight: normal;
  padding: 8px;
  text-align: center;
}

#callSheet td {
  background: none repeat scroll 0 0 #E8EDFF;
  border-top: 1px solid #FFFFFF;
  color: #666699;
  padding: 8px;
}

#callSheet tbody tr:hover td {
  background: none repeat scroll 0 0 #D0DAFD;
}
  • 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-05-19T11:48:01+00:00Added an answer on May 19, 2026 at 11:48 am

    UPDATE:
    This problem seems to be caused by using margin-left:auto and margin-right:auto on the elements that you’re anmiating. While the animation is happening, you get a snap-left behavior.

    To fix, simply move the auto margins to the higher-level container, and set the child elements to width:100%. I used inline styles in my sample but this should work wherever the styles are defined.

    Like this:

    <div class="container400" > 
        <div id="selectedEmployee" style="width:100%;"> 
            <div class="currentEmp"> 
                <div class="currentEmpName"> 
                    Last, First <br /> 
                    <span class="empWorkUnit">Work Unit</span> 
                </div> 
    
                <div id="editEmpInfo"><a title="Edit" href="#">Edit</a></div> 
                        <div class="currentEmpInfo"> 
                    <div>Ext: </div> 
                    <div>Cell: </div> 
                    <div>Home: </div> 
                    <div>Pager: </div> 
                    <div>Other: </div> 
    
                    <div>Notes: </div> 
                </div> 
            </div> 
        </div> 
    
        <div id="editSelectedEmployee" class="hidden" style="width:100%;"> 
            <div class="currentEmp"> 
                <div class="currentEmpName"> 
                    Last, First <br /> 
    
                    <span class="empWorkUnit">Work Unit</span> 
                </div> 
                <div id="saveEmpInfo"><a title="Save" href="#">Save</a></div> 
                <div class="currentEmpInfo"> 
                    <div>Ext: </div> 
                    <div>Cell: </div> 
                    <div>Home: </div> 
    
                    <div>Pager: </div> 
                    <div>Other: </div> 
                    <div>Notes: </div> 
                </div> 
            </div> 
        </div> 
    </div>
    

    OLD ANSWER: (the trick below works true in some cases, although clearly not yours!)

    I’ve run into this problem on various non-IE browsers including Firefox and Chrome. I was able to work around it by adding inline styles (yuck!) to the container element that you’re animating.

    The inline styles required are: display:block; plus setting all margin widths explicitly. For example:

    <div id="badSnappingElement" style="display: block; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">
    

    It’s the inline styles that makes it work. Using CSS for this won’t prevent the problem.

    Your setup is a little complicated because there are two different elements being hidden and shown, so you may need to experiment to find the right element(s) to attach the inline styles to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div that is created by Ajax with .append(html) function, I'm trying
I am trying to have an advertisement block/div that will be switched to a
I have a div that expands to the height of it's content. It works
I have a div that is absolutely positioned from the top left corner of
i have a div that it have image content .i wanna implement animation when
I'm trying to figure out how to have a div dynamically resize, based on
I have a div that is scrolling vertically. I, however, really want it to
This one has been driving me nuts. I have a div that has it's
I have a div class that looks something like this: <div class=objects> X </div>
I have a div element that I'm trying, basically, to move wherever the user

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.