如何设置动画速度,使其以每秒2像素的速度移动?这里我的块的长度是310像素。我希望它以每秒2像素的速度移动。

$('#one').mouseenter(function(){
 $('.alt0').animate({width: "310px"}, 150000, function(){
    $('#refresh-1').show();
})
 $('#song-title1').show()
});
$('#refresh-1').click(function(){
$('.alt0').width(0);
$(this).hide();
})

最佳答案

将动画持续时间设置为310/2*1000(每像素半秒乘以1000毫秒),并将动画缓和为“线性”。

$('.alt0').animate( {width: "310px"}, 310/2*1000, "linear" );

Code here

07-28 02:27