javascriptjquerycssheightanythingslider

AnythingSlider with dynamic height?


I am using anythingslider and have a problem.

My content elements get loaded from a CMS and their height can vary. I would like to set the slider height to the height of the tallest element, but this doesn't seem to work.

I tried it like this:

var max_height = 0;
$(".canythingslider .ccontentelement").each(function() {
    var h = $(this).height();
    if(h > max_height) {max_height = h;}
});
$(".canythingslider").css("height", max_height + "px");
$(".canythingslider").anythingSlider();

Does anyone have an idea how to solve this?


Solution

  • I got it to work now. The resizeContents option of AnythingSlider has to be set to false, then the above script does what I want.