您可以采用这种方法,扩展 Brad M 的答案:
http://jsfiddle.net/mori57/Gqttc/
鉴于此 HTML:
<div id="clickme">Click here</div>
<div id="lines">
<div id="line1">
<img src="http://placehold.it/350x40" alt="" />
</div>
<div id="line2">
<img src="http://placehold.it/350x40" alt="" />
</div>
<div id="line3">
<img src="http://placehold.it/350x40" alt="" />
</div>
</div>
这个CSS:
#lines div {
opacity:0;
margin-left:-400px
}
您可以使用 jQuery 采用这种方法:
// get your lines into an array
var lines = $("#lines div");
// set a counter
var currAnim = 0;
// this method will animate a line
var fadeMoveIn = function (line) {
$(line).animate({
opacity: 1,
marginLeft: 10
}, {
queue: true,
duration: 1000,
complete: function () {
// when this line's animation is done
// trigger the next in the queue
startQueue();
}
});
};
// this function will fire off your animations one by one
var startQueue = function () {
// increment the queue and send that line to be animated
fadeMoveIn(lines[currAnim++]);
};
$("#clickme").click(function () {
startQueue();
});
希望能给你一些关于如何管理它的想法!Brad 的方法是一个好的开始,但它会同时为所有 div 设置动画,这不是我认为您正在寻找的效果。