我已经创建了一个使用jQuery循环的幻灯片,并且每个幻灯片div都包含包含图像和文本的子div,并且想知道是否可以动画文本在每个幻灯片之后的其中一个子div使用'onAfter'显示。基本上我想知道是否可以在幻灯片放映完成后为幻灯片div内的任何动画制作动画。一旦显示幻灯片,我似乎无法得到任何事情发生或动画。使用jquery循环插件,旋转后幻灯片内的动画元素
//Run the slide show:
$('#slide').cycle({
fx: 'fade',
timeout: 1000,
after: onAfter,
});
//function to animate element within the '#slide' div after slide is rotated in
function onAfter() {
$('#slide div .right').animate({
easing: 'linear',
//shrink the font size down
fontSize : '18px',
}, 2000, function() {
// Animation complete.
});
};
这里的HTML:
<div id="slide">
<div><!--slide 1-->
<div class="left"><img src="images/theimage1.jpg" alt="An Image" /></div>
<div class="right">this is the text I want to animate once the slide is shown</div>
</div>
<div><!--slide 2-->
<div class="left"><img src="images/theimage2.jpg" alt="An Image" /></div>
<div class="right">animate more text once this slide is displayed</div>
</div>
<div><!--slide 3-->
<div class="left"><img src="images/theimage3.jpg" alt="An Image" /></div>
<div class="right">animate this text when slide 3 is shown</div>
</div>
</div><!--end #slide -->
这里的CSS:
<style type="text/css" media="all">
#slide { width: 950px; border: none; background-color: #fff; }
#slide div { width: 100%; }
#slide div .left {float: left; width: 350px; padding: 0;}
#slide div .right {float: right; color: #666; font-size: 40px; width: 560px; }
</style>
我将图像和文本放在单独的div(不在eachother内),并使用CSS将文本放置在图像顶部。 – kamalo 2012-02-21 17:37:32