I have a container div that need to be flexible in height because the content inside the div can change when users click on the button.
<div id="container">
<div id="divBuyNow">
<button id="btnBuyNow">
Buy Now</button>
</div>
</div>
$("#btnBuyNow").click(function () {
$("#divBuyNow").animate({
opacity: 0,
marginRight: '200px'
}, 1000, function () {
$("#divBuyNow").hide();
});
$("#platformsContainer").animate({
opacity: 1,
marginRight: '170px'
}, 2000);
});
What I understand is you want to animate
platformContainerto height based on the content. If yes, setoverflow:hiddento container and modify contents to innerDiv inside the container withopacity:0. When you want to show, get the height of innerDiv and animate container div to height + margins and other offset.