I have a simple text inside span. I just wanted to animate it from right to center of the #maincontainer.
Therefore i did a calculation to make it center horizontally. I tried with outerWidth() as well. It didn't work. Here is the code.
<span id="headline">Hi There! Say hello to world.</span>
#maincontainer width is 728m But #headline container is giving wrong calculation every time.
$("#headline").css({"top": (($("#maincontainer").height()-($("#headline").height()))/2)}).delay(1e3).animate({
"right": $("#maincontainer").width() - $("#headline").width() + "px"
},5e2);