In the jQuery example below, I have one div inside another. When I animate the inner div down to a width of 0, the outer div (which has absolute positioning), decreases in width along with it.
This is desired.
The trouble is that after the animation is complete, the outer div pops back to its original size. Is this expected? How can I keep this from happening?
Thanks!
Example
html:
<div class="outer"><div class="inner">innerContent</div></div>
css:
div.outer {
position: absolute;
padding: 10px;
background: purple;
}
div.inner {
position: relative;
padding-left: 5px;
padding-right: 5px;
background: orange;
clip: auto; overflow: hidden;
}
javascript:
$('.outer').click(function() {
$('.inner').animate({width: 0, paddingLeft: 0, paddingRight: 0}, 'slow');
});