When I was building a campus video website, there was a navigation page on the homepage that needed to achieve a scrolling effect. There were examples, but the code was difficult to understand. It seemed that in web design, only my own code was understood, so I simply imitated the effects of others. I made one myself, and it's generally OK. It looks relatively smooth, not inferior to the original one.
Copy the code here now, and simplify the modifications one by one later:
To achieve the scrolling effect, the script code is as follows:
var all=0;
var no=0;
var s_width=0;
$(document).ready( function(){
all=$('.slide').length;
s_width=$('.slide').eq(0).width();
$("#slides" ).css('width',all*s_width);
var contiar=$('.control_links');
for(var i=0;i
contiar.append ("");
}
$('.control_links li').bind('click mouseenter',function(){
var index=$(this ).index();
no=index;
var no_= no%all;
$("#slides").animate({left:(-1*no_*s_width) 'px' },200);
$(this).css('background-color','#fff');
$(this).siblings().css('background-color','#333 ');
});
setInterval(function(){
var no_= no%all;
$("#slides").animate({left:(-1*no_* s_width) 'px'},1000);
var curr= $('.control_links li').eq(no_);
curr.css('background-color','#fff')
curr.siblings().css('background-color','#333');
no ;
},5000);
});
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn