Using jQuery to adjust a parent element's height to match it's visible child's height

前端 未结 3 2006
盖世英雄少女心
盖世英雄少女心 2021-01-28 03:18

I\'ve got a slideshow running in a container and need the height of the container to match the visible slide\'s height. Unfortunately the images are absolutely positioned and th

3条回答
  •  离开以前
    2021-01-28 03:58

    I'd suggest using the plug-in's callback options, particularly the after:

    $('.home').cycle({
        fx:'fade',
        after: function(){
            $('#main').css('height',$(this).outerHeight());
        }
    });
    

    Updated JS Fiddle demo.

    References:

    • cycle() plug-in's 'callback' documentation/demonstration

提交回复
热议问题