图片向上、向下、向左、向右不间断无缝滚动.

  图片向下滚动:

<div id="colee" style="overflow: hidden; height: 253px; width: 410px;">
<div id="colee1">
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
</div>
<div id="colee2">
</div>
</div>
<script type="text/javascript">
var speed = ;
var colee2 = document.getElementById("colee2");
var colee1 = document.getElementById("colee1");
var colee = document.getElementById("colee");
colee2.innerHTML = colee1.innerHTML; //克隆colee1为colee2
function Marquee1() {
//当滚动至colee1与colee2交界时
if (colee2.offsetTop - colee.scrollTop <= ) {
colee.scrollTop -= colee1.offsetHeight; //colee跳到最顶端
} else {
colee.scrollTop++
}
}
var MyMar1 = setInterval(Marquee1, speed)//设置定时器
//鼠标移上时清除定时器达到滚动停止的目的
colee.onmouseover = function () { clearInterval(MyMar1) }
//鼠标移开时重设定时器
colee.onmouseout = function () { MyMar1 = setInterval(Marquee1, speed) }
</script>

  图片向下滚动

<div id="colee_bottom" style="overflow: hidden; height: 253px; width: 410px;">
<div id="colee_bottom1">
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
</div>
<div id="colee_bottom2">
</div>
</div>
<script>
var speed =
var colee_bottom2 = document.getElementById("colee_bottom2");
var colee_bottom1 = document.getElementById("colee_bottom1");
var colee_bottom = document.getElementById("colee_bottom");
colee_bottom2.innerHTML = colee_bottom1.innerHTML
colee_bottom.scrollTop = colee_bottom.scrollHeight
function Marquee2() {
if (colee_bottom1.offsetTop - colee_bottom.scrollTop >= )
colee_bottom.scrollTop += colee_bottom2.offsetHeight
else {
colee_bottom.scrollTop--
}
}
var MyMar2 = setInterval(Marquee2, speed)
colee_bottom.onmouseover = function () { clearInterval(MyMar2) }
colee_bottom.onmouseout = function () { MyMar2 = setInterval(Marquee2, speed) }
</script>

  图片向左滚动

<div id="colee_left" style="overflow: hidden; width: 500px;">
<table cellpadding="" cellspacing="" border="">
<tr>
<td id="colee_left1" valign="top" align="center">
<table cellpadding="" cellspacing="" border="">
<tr align="center">
<td>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
</td>
<td>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
</td>
<td>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
</td>
<td>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
</td>
<td>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
</td>
<td>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
</td>
<td>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
</td>
</tr>
</table>
</td>
<td id="colee_left2" valign="top">
</td>
</tr>
</table>
</div>
<script>
//使用div时,请保证colee_left2与colee_left1是在同一行上.
var speed = //速度数值越大速度越慢
var colee_left2 = document.getElementById("colee_left2");
var colee_left1 = document.getElementById("colee_left1");
var colee_left = document.getElementById("colee_left");
colee_left2.innerHTML = colee_left1.innerHTML
function Marquee3() {
if (colee_left2.offsetWidth - colee_left.scrollLeft <= )//offsetWidth 是对象的可见宽度
colee_left.scrollLeft -= colee_left1.offsetWidth//scrollWidth 是对象的实际内容的宽,不包边线宽度
else {
colee_left.scrollLeft++
}
}
var MyMar3 = setInterval(Marquee3, speed)
colee_left.onmouseover = function () { clearInterval(MyMar3) }
colee_left.onmouseout = function () { MyMar3 = setInterval(Marquee3, speed) }
</script>

  图片向右滚动

<!--下面是向右滚动代码-->
<div id="colee_right" style="overflow: hidden; width: 500px;">
<table cellpadding="" cellspacing="" border="">
<tr>
<td id="colee_right1" valign="top" align="center">
<table cellpadding="" cellspacing="" border="">
<tr align="center">
<td>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
</td>
<td>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
</td>
<td>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
</td>
<td>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
</td>
<td>
<p>
<img src="/jscss/demoimg/200907/bg3.jpg"></p>
</td>
</tr>
</table>
</td>
<td id="colee_right2" valign="top">
</td>
</tr>
</table>
</div>
<script>
var speed = //速度数值越大速度越慢
var colee_right2 = document.getElementById("colee_right2");
var colee_right1 = document.getElementById("colee_right1");
var colee_right = document.getElementById("colee_right");
colee_right2.innerHTML = colee_right1.innerHTML
function Marquee4() {
if (colee_right.scrollLeft <= )
colee_right.scrollLeft += colee_right2.offsetWidth
else {
colee_right.scrollLeft--
}
}
var MyMar4 = setInterval(Marquee4, speed)
colee_right.onmouseover = function () { clearInterval(MyMar4) }
colee_right.onmouseout = function () { MyMar4 = setInterval(Marquee4, speed) }
</script>

JavaScript- 图片无缝滚动的更多相关文章

  1. Javascript图片无缝滚动

    http://www.cnblogs.com/shouce/p/5068787.html

  2. 应用JavaScript搭建一个简易页面图片无缝滚动效果

    页面图片无缝滚动JavaScript原理:移动的区块包含图片内容,区块相对父级元素进行定位脱离文档流.再令区块的left值每隔固定的时间进行等量减少(或增大)从而实现区块的匀速运动.由于每次间隔移动的 ...

  3. JavaScript学习笔记5 之 计时器 & scroll、offset、client系列属性 & 图片无缝滚动

    一.计时器 setInterval ( 函数/名称 , 毫秒数 )表示每经过一定的毫秒后,执行一次相应的函数(重复) setTimeout ( 函数/名称 , 毫秒数 ) 表示经过一定的毫秒后,只执行 ...

  4. jQuery图片无缝滚动JS代码ul/li结构

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. jQuery图片无缝滚动

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

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

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. CSS和jQuery分别实现图片无缝滚动效果

    一.效果图 二.使用CSS实现 <!DOCTYPE html> <html> <head> <meta charset="utf-8"&g ...

  8. Javascript实现图片无缝滚动

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. javascript实现图片无缝滚动(scrollLeft的使用方法介绍)

    <!DOCTYPE html > <html> <head> <meta http-equiv="Content-Type" conten ...

  10. JavaScript----marquee滚动标签 图片无缝滚动 插入百度地图

    页面的自动滚动效果,可由javascript来实现, 但是有一个html标签 - <marquee></marquee>可以实现多种滚动效果,无需js控制. 使用marquee ...

随机推荐

  1. nutch 采集到的数据与实际不符

    现象,这个网站我总计能抽取将近500个URL,但实际只抽取了100条 解析:nutch默认从一个页面解析出的链接,只取前 100 个. <property> <name>db. ...

  2. Portlet 通信过程详解

    Portlet 通信过程详解 在 Portal 的开发过程中,Theme 与 portlet 之间的通信,以及 portlet 之间的通信是开发人员常常遇到的问题.通常 Portlet 之间需要能够互 ...

  3. HDOJ多校联合第六场

    先一道一道题慢慢补上, 1009.题意,一棵N(N<=50000)个节点的树,每个节点上有一个字母值,给定一个串S0(|S0| <=30),q个询问,(q<=50000),每次询问经 ...

  4. 点点滴滴-NET下的常用框架

    刘冬的博客:http://www.cnblogs.com/GoodHelper/category/214139.html (Spring.net和Nhibernate) Kyo-yo  : http: ...

  5. API:System V & POSI

    http://blog.sina.com.cn/s/blog_5b1572e30100gulz.html

  6. js中replace用法

    js中replace的用法 replace方法的语法是:stringObj.replace(rgExp, replaceText) 其中stringObj是字符串(string),reExp可以是正则 ...

  7. SpringBoot入门 一 构建简单工程

    环境准备:jdk1.7(推荐)以上,tomcat8(推荐)以上,或者使用插件自带.mevan插件3.2以上,eclipse编辑工具 pom文件基本配置如下 <project xmlns=&quo ...

  8. poj1160Post Office(DP)

    http://poj.org/problem?id=1160 算水过的吧 四重循环没优化 CZ说爆可过 就爆了 dp[i][j] = min(dp[i][j],dp[i-1][g]-s) 第i个点建在 ...

  9. MySQL information_schema表查询导致内存暴涨

    case:下面的一条sql语句,导致mysql实例内存暴涨: select * from tables where table_name not in(select table_name from p ...

  10. NOI2010航空管制

    2008: [Noi2010]航空管制 Time Limit: 10 Sec  Memory Limit: 552 MBSubmit: 31  Solved: 0[Submit][Status] De ...