我正在尝试让容器自动计算高度,并使用以下代码,但没有运气。
该容器名为#features-content
/* <![CDATA[ */
var jqu = jQuery.noConflict();
jqu( function () {
/* Cycle */
jqu( '#featured-content' ).cycle( {
slideExpr: '.featured-post',
fx: 'fade',
speed: 1000,
cleartypeNoBg: true,
pager: '#slide-thumbs',
containerResize: true,
slideResize: false,
width: '100%',
timeout: 5000,
prev: '#slider-prev',
next: '#slider-next',
pagerAnchorBuilder: function( idx, slide ) {
// return selector string for existing anchor
return '#slide-thumbs li:eq(' + idx + ') a';
}
} );
// call back function to animate the height of the container
function onAfter(curr, next, opts, fwd) {
var index = opts.currSlide;
$('#slider-prev')[index == 0 ? 'hide' : 'show']();
$('#slider-next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
//get the height of the current slide
var $ht = $(this).height();
//animates the container's height to that of the current slide
$(this).parent().animate({ height: $ht });
}
} );
/* ]]> */
答案 0 :(得分:0)
未启动回调功能
after: onAfter,
还可以尝试动画“快速”
$(this).parent().animate({ height: $ht }, "fast");
只需在此处添加代码http://tny.cz/935e48e2