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 8052479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:33:20+00:00 2026-06-05T07:33:20+00:00

There is a container div (#content) with 10px padding and its content (#inner_content) .

  • 0

There is a container div (#content) with 10px padding and its content (#inner_content). I’m loading some new stuff via ajax (the new html contains everything in a #inner_content div) and replace #content's html with the new html.

While doing this I want the height of the container div (#content) to adjust to the height of the new content by animation. So I have set overflow: hidden for the container div and when I load new content, I get its height and animate the container div to the same height. All is good expect that sometimes the height is somewhat bigger (10-20 pixels maybe) than needed and that’s causing trouble to the design.

So I put a complete function on the .animate() to set the height of the container div to ” (auto) after the animation has completed so that the height is correct. The problem is that the complete function runs immediately, the animation is skipped and the height becomes auto instantly. Here’s the code:

$("#content").html(response); 
$("#content").animate({height: $("#inner_content").height()+"px"}, 300, function () {
$("#content").css({height: ''});
});

How can I solve this problem? I need the animation to be executed then the height set to auto (this causes a small ‘gap’ in the proccess because the div immediately gets 10-20px shorter but it’s ok.

  • 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-05T07:33:21+00:00Added an answer on June 5, 2026 at 7:33 am

    Hmm, without any source code it’s tricky, but my gut instinct is saying, for some reason, your #content and #inner_content divs are actually the same height (I’m guessing 0), which is causing the animation to execute instantly, thus firing the event immediately as well.

    Are you able to provide any source?

    I would recommend first playing with the outerHeight() method on the divisions and see what happens. Additionally, try turning off the overflow: hidden and instead try the following pseudo-code:

    1. Load the new content in a hidden separate div
    2. Get the height of the new content
    3. Animate the current content
    4. Update the current content with the new content
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a layout with a container (div), inside the container there are
I have a resizable container div. Inside that div there's another resizable div. If
I have a container (div) with a background image. In this div there is
There's a demo here > http://jsfiddle.net/AndyMP/4hzXe/ I can't figure out why the container DIV
Is there any way to disable all input fields in an div container with
I have a website with the following setup: <div id=container> <div id=header></div> <div id=content></div>
I am currently using the .load() function to load content into a container div
i have inside the body main 'container' div and inside this 'container' div there
Beginner page building question: I've got a simple /div container defined via a CSS
I have this code: <div class=container id=container> <div class=content id=content> <div class='nav'> <ul> <li><a

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.