@Dean,您最好结合使用 CSS 和 jQuery 来完成这项工作——这是为了解决图像缓存问题(请参阅 Nick 的回复以获取解释)。这是一个粗略的例子:
CSS:
#mike {
display: block;
margin: 0; padding: 0; /* Ignore this if you're using a reset.css */
position: absolute; /* Change this to relative based on the containing elements */
top: 2000px; /* Assumes you have an image that's 100px tall as an example */
}
jQuery:
jQuery( function(){
$('#mike').animate({'top':'0'},255,'linear', function(){
console.log('Done Animation);
});
} );
您还可以在页面加载后将动画延迟几秒钟(或几毫秒):
jQuery( function(){
// Delay the animation by 1 second after page load before animating.
$('#mike').delay(1000).animate({'top':'0'},255,'linear', function(){
console.log('Done Animation);
});
} );