I am facing an issue with a container that displays products. The container is currently set to only show a few products, but there is a button that increases the height to display all products. The problem is that the height needs to change dynamically based on the number of products added via the CMS. Is there a way to adjust the height of the container to always display all products without hard-coding the height?
Fiddle: http://jsfiddle.net/Vx53r/1/
UP DOWN
HTML:
<div class="box">Product</div>
<div class="box">Product</div>
<div class="box">Product</div>
<div class="box">Product</div>
<div class="box">Product</div>
<div class="box">Product</div>
<div class="box">Product</div>
<div class="box">Product</div>
<div class="box">Product</div>
<div class="box">Product</div>
<div class="box">Product</div>
</div>
CSS:
.container{
background:grey;
width:500px;
height:200px;
overflow:hidden;
}
.box{
width:120px;
height:220px;
background:pink;
margin:10px;
float:left;
}
JS:
$('#btn-down').click(function(){
$('.container').animate({height:'630px'}, 500);
});
$('#btn-up').click(function(){
$('.container').animate({height: '200px'}, 500);
});