http://jsfiddle.net/ncrqb/21/
function centerBlue(){ var blue = $("#rightbot"); var parent = $("#left"); var rightTop = $("#righttop"); var left_space = (parent.outerHeight() - rightTop.outerHeight()) - 5; blue.css("height",left_space+"px"); console.log(rightTop.outerHeight()); }
Here is the solution, and it works.
All these answers are correct, but they just forgot that you need to resize the blue field after the animation is complete, otherwise jQuery will return the previous height of the slide state.
And this is because jQuery animates using window.setTimeout (); and why it does not block the code, only the animation is executed.
source share