[英]How do I make a div appear, then slide all the way to the right, then fade out slowly?
我将如何在JQuery中做到这一点?
In short: 简而言之:
Here is an quick shot which would do the trick. 这是可以解决问题的快速快照。 http://jsfiddle.net/LGBUJ/ http://jsfiddle.net/LGBUJ/
Did you know that jQuerys chaining is really great?! 您是否知道jQuery链接真的很棒?!
"animate()" has a "complete" option. “ animate()”具有“完整”选项。 You supply a function that you want to run once the animate has completed. 您提供了要在动画完成后立即运行的功能。 So, for the first animate (appear), you have a complete function that does another animate (slide-right). 因此,对于第一个动画(出现),您具有完成另一个动画(向右滑动)的完整功能。 That animate has as its complete function another animate (fade out slowly). 该动画具有完整的功能,即另一个动画(逐渐消失)。
In this way each one starts when the previous completes. 这样,每一个都在前一个完成时开始。
Regards Neil 问候尼尔
Give your element a position:absolute
and give this a try, it might be off a few pixels (padding and borders). 给您的元素一个position:absolute
并尝试一下,它可能会偏离几个像素(填充和边框)。
var elm = $('#YourElmID');
var maxLeft = $('body').width() - elm.width();
elm.fadeIn();
elm.animate({left: maxLeft}, 2000, function(){
elm.fadeOut();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.