2023年7月9日发(作者:)
基于JQuery实现的跑马灯效果(⽂字⽆缝向上翻动)(function($){ $.({ "slideUp":function(value){
var docthis = this; //默认参数 value=$.extend({ "li_h":"30", "time":2000, "movetime":1000 },value)
//向上滑动动画 function autoani(){ $("li:first",docthis).animate({"margin-top":-_h},me,function(){ $(this).css("margin-top",0).appendTo(".line"); }) } //⾃动间隔时间向上滑动 var anifun = setInterval(autoani,);
//悬停时停⽌滑动,离开时继续执⾏ $(docthis).hover(function(){ clearInterval(anifun); //清除⾃动滑动动画 },function(){ setInterval(autoani,); //继续执⾏动画 }) }
})})(jQuery) 主要思路: 滑动动画,就是改变元素的位置,要改变元素的位置有两种⽅法,⼀种改变left,top属性(相对定位和绝对定位),还有⼀种,就是现在这⾥⽤到的,改变margin的值。 上例中动画过程: 1.设置要改变margin-top的值; 2.⽤animate⽅法改变第⼀个LI的margin-top的值为-30(负值会向上移动); 3.在动画完成之后,回调函数内,把当前的第⼀个LI的margin-top改变为"0" 4.把当前这第⼀个LI移动到所有LI的最后⼀个。(实现⽆缝)以上就是本⽂的全部内容,希望对⼤家有所帮助,谢谢对的⽀持!
发布者:admin,转转请注明出处:http://www.yc00.com/web/1688851203a176576.html
评论列表(0条)