无缝滚动代码

<!doctype html>
<html>
<head>
<!--声明当前页面的编码集:charset=gbk,gb2312(中文编码),utf-8国际编码-->
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<!--当前页面的三要素-->
<title>demo</title>
<meta name="Keywords" content="关键词,关键词">
<meta name="description" content="">

<!--css,js-->
<style type="text/css">
*{margin:0;padding:0;}
.banner{width:1000px;height:480px;margin:100px auto;}
.banner .box{width:1000px;height:480px;position:relative;overflow:hidden;}
.banner .box .btn{width:32px;height:480px;position:absolute;background:rgba( 0 , 0 , 0 ,.5);}
.banner .box .btn_left{left:0;background-image:url(‘images/btn_left.png‘);background-repeat:no-repeat;background-position:center;}
.banner .box .btn_right{right:0;background-image:url(‘images/btn_right.png‘);background-repeat:no-repeat;background-position:center;}
.banner .box ul{width:8000px;height:480px;position:absolute;left:0;}
.banner .box ul li{float:left;position:relative;list-style:none;}
.banner .box ul li img{float:left;border:0;}
.banner .box ul li .description{width:1000px;height:30px;position:absolute;bottom:0;font-size:18px;font-family:"microsoft Yahei";line-height:30px;text-align:center;background:rgba( 0 , 0 , 0 ,.5);}
</style>
</head>
<body>
<div class="banner">
<div class="box">
<ul>
<li>
<img src="images/6.jpg" width="640" height="480" /><img src="images/6-6.jpg" width="360" height="480" />
<div class="description">第一组图</div>
</li>
<li>
<img src="images/1.jpg" width="640" height="480" /><img src="images/1-1.jpg" width="360" height="480" />
<div>第二组图</div>
</li>
<li>
<img src="images/2.jpg" width="640" height="480" /><img src="images/2-2.jpg" width="360" height="480" />
<div>第三组图</div>
</li>
<li>
<img src="images/3.jpg" width="640" height="480" /><img src="images/3-3.jpg" width="360" height="480" />
<div>第四组图</div>
</li>
<li>
<img src="images/4.jpg" width="640" height="480" /><img src="images/4-4.jpg" width="360" height="480" />
<div>第五组图</div>
</li>
<li>
<img src="images/5.jpg" width="640" height="480" /><img src="images/5-5.jpg" width="360" height="480" />
<div>第六组图</div>
</li>
<li>
<img src="images/6.jpg" width="640" height="480" /><img src="images/6-6.jpg" width="360" height="480" />
<div>第一组图</div>
</li>
<li>
<img src="images/1.jpg" width="640" height="480" /><img src="images/1-1.jpg" width="360" height="480" />
<div>第二组图</div>
</li>
</ul>
<div class="btn_left btn"></div>
<div class="btn_right btn"></div>
</div>
</div>
<script src="js/jquery-1.11.1.min.js"></script>
<script>
/*$(document).ready(function(){});所有的函数都放在这里面,这是为了防止文档在完全加载(就绪)之前运行jQuery代码。*/
$(document).ready(function(){
var num=0;
var timer=null;
/*移入事件,停止定时器,移出事件,增加定时器*/
$(".banner .box").hover(function(){
clearInterval(timer);
},function(){
autoPlay();
});
/*点击左按钮*/
$(".banner .box .btn_left").click(function(){
move();
});
/*点击右按钮*/
$(".banner .box .btn_right").click(function(){
move_right();
});
/*自动播放函数*/
function autoPlay(){
timer = setInterval(function(){
move();
des_show();
},2000);
}
autoPlay();
/*向左移动函数*/
function move(){
num++;
if(num>6){
num = 1;
$(".box ul").css({"left":"0px"});
$(".box ul").stop().animate({left:-1000*num},200);
}else{
$(".box ul").stop().animate({left:-1000*num},200);
}
des_show();
}
/*向右移动函数*/
function move_right(){
num--;
if(num<0){
num = 5;
$(".box ul").css({"left":"-6000px"});
$(".box ul").stop().animate({left:-1000*num},200);
}else{
$(".box ul").stop().animate({left:-1000*num},200);
}
des_show();
}
/*文字描述显示*/
function des_show(){
$(".box ul li").eq(num).find("div").addClass("description").siblings().removeClass("description");
}
});
</script>
</body>
</html>

时间: 2024-08-29 19:45:49

无缝滚动代码的相关文章

jquery图片无缝滚动代码左右 上下无缝滚动图片

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-

js图片无缝滚动代码

想必大家都注意到<marquee>的不循环滚动,所以出现了很多替代脚本,或iframe或JS输出<marquee>,不管怎么做,都略显麻烦.下面说一下这个相对简单的实现思路:一个设定宽度并且隐藏超出它宽度的内容的容器demo,里面放demo1和 demo2,demo1是滚动内容,demo2为demo1的直接克隆,通过不断改变demo1的scrollTop或者scrollLeft达到滚动的目的,当滚动至demo1与demo2的交界处时直接跳回初始位置,因为demo1与demo2一样,

JavaScript(六)——实现图片上下或者左右无缝滚动

/*! jQuery v1.8.3 jquery.com | jquery.org/license */ (function(e,t){function _(e){var t=M[e]={};return v.each(e.split(y),function(e,n){t[n]=!0}),t}function H(e,n,r){if(r===t&&e.nodeType===1){var i="data-"+n.replace(P,"-$1").toL

jquery图片无缝滚动特效

jquery图片无缝滚动插件制作左右无缝滚动图片和上下无缝滚动图片,一款简单的jQuery无缝滚动代码.JS代码 <script type="text/javascript"> //图片滚动 调用方法 imgscroll({speed: 30,amount: 1,dir: "up"}); $.fn.imgscroll = function(o){ var defaults = { speed: 40, amount: 0, width: 1, dir:

JS图片无间断滚动代码合集

JavaScript图片滚动代码合集,向上下左右四个方向的无缝滚动代码,前端设计开发时所能用的一个图片特效,你可只用其中的一种滚动.前端框架分享 .代码   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1

图片切换特效(2):JS图片滚动代码(无缝、平滑)

转自:http://www.codefans.net/jscss/code/255.shtml <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">

banner轮播无缝滚动万金油jq代码

HTML: <div class="box"> <ul> <li>11111</li> <li>22222</li> </ul> </div> JQ: 调用:$(function(){ setinterval(functon(){ scroll($(".box ul")); },1000); }) 封装:function scroll(obj){ var h=obj.fi

JS实现Li列表的无缝垂直文字滚动代码

非Table模式的新闻列表滚动,学习CSS的朋友可能都能做出这种效果来.运用了CSS中的Li列表标签,加上javaScript代码控制,完成完美的无缝滚动效果.在兼容性方面,在ie6,7,8,9,firefox等主流浏览器下均测试通过,用的时候您只需改变一下样式和大小,再将Js封装起来,用时候调用,就更简洁了,相信这款实用的文字滚动正是你需要的. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http

无缝滚动js代码

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <meta charset="UTF-8"> <title>无缝滚动</title> <style> * {margin: 0;padd