[转]不间断连续图片滚动效果的制作方法(JS)

简介: From: http://x8.maicoo.com/tech/9/225.html以前我们站点也介绍过连续滚动的图片,但缺陷是有间断。如何制作连续不间断的播放滚动呢?请参看制作方法:  先制作向上滚动的效果:(演示:http://x8.
From: http://x8.maicoo.com/tech/9/225.html

以前我们站点也介绍过连续滚动的图片,但缺陷是有间断。如何制作连续不间断的播放滚动呢?请参看制作方法:
  先制作向上滚动的效果:(演示: http://x8.maicoo.com/tech/9/225.html)
img_a6339ee3e57d1d52bc7d02b338e15a60.gif <!--  指向链接图片url  -->
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< base  href ="http://www.it365cn.com" >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< div  id =demo  style =overflow:hidden;height:150;width:90;background:#214984;color:#ffffff >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< div  id =demo1 >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
<!--  定义图片  -->
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< img  src ="images/logo_1.gif" >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< img  src ="images/logo/flashempire.gif" >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< img  src ="images/logo.gif" >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< img  src ="images/logo/5dmedia.gif" >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< img  src ="images/logo/macromedia.gif" >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< img  src ="images/logo/sucaiw.gif" >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< img  src ="images/logo/blueieda.gif" >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< img  src ="images/logo/htmlcn.gif" >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< img  src ="images/logo/fwcn.gif" >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
</ div >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< div  id =demo2 ></ div >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
</ div >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_405b18b4b6584ae338e0f6ecaf736533.gifimg_1c53668bcee393edac0d7b3b3daff1ae.gif
< script > img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif
img_33d02437d135341f0800e3d415312ae8.gif
var speed=30
img_33d02437d135341f0800e3d415312ae8.gifdemo2.innerHTML
=demo1.innerHTML
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
function Marquee()img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif
if(demo2.offsetTop-demo.scrollTop<=0)
img_33d02437d135341f0800e3d415312ae8.gifdemo.scrollTop
-=demo1.offsetHeight
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
elseimg_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gifdemo.scrollTop
++
img_105a1e124122b2abcee4ea8e9f5108f3.gif}

img_105a1e124122b2abcee4ea8e9f5108f3.gif}

img_33d02437d135341f0800e3d415312ae8.gif
var MyMar=setInterval(Marquee,speed)
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gifdemo.onmouseover
=function() img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{clearInterval(MyMar)}
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gifdemo.onmouseout
=function() img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{MyMar=setInterval(Marquee,speed)}
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
</ script >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif

制作向下滚动的效果:
  将上面“制作向上滚动的效果”中的红色字体Js部分替换成:
img_405b18b4b6584ae338e0f6ecaf736533.gif img_1c53668bcee393edac0d7b3b3daff1ae.gif < script > img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif
img_33d02437d135341f0800e3d415312ae8.gif
var speed=30
img_33d02437d135341f0800e3d415312ae8.gifdemo2.innerHTML
=demo1.innerHTML
img_33d02437d135341f0800e3d415312ae8.gifdemo.scrollTop
=demo.scrollHeight
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
function Marquee()img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif
if(demo1.offsetTop-demo.scrollTop>=0)
img_33d02437d135341f0800e3d415312ae8.gifdemo.scrollTop
+=demo2.offsetHeight
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
elseimg_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gifdemo.scrollTop
--
img_105a1e124122b2abcee4ea8e9f5108f3.gif}

img_105a1e124122b2abcee4ea8e9f5108f3.gif}

img_33d02437d135341f0800e3d415312ae8.gif
var MyMar=setInterval(Marquee,speed)
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gifdemo.onmouseover
=function() img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{clearInterval(MyMar)}
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gifdemo.onmouseout
=function() img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{MyMar=setInterval(Marquee,speed)}
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
</ script >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif

制作向左滚动的效果:
img_a6339ee3e57d1d52bc7d02b338e15a60.gif < base  href ="http://www.it365cn.com" >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< div  id =demo  style =overflow:hidden;height:33;width:500;background:#214984;color:#ffffff >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< table  align =left  cellpadding =0  cellspace =0  border =0 >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< tr >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< td  id =demo1  valign =top >< img  src ="images/logo_1.gif" >< img  src ="images/logo/flashempire.gif" >< img  src ="images/logo.gif" >< img  src ="images/logo/5dmedia.gif" >< img  src ="images/logo/macromedia.gif" >< img  src ="images/logo/sucaiw.gif" >< img  src ="images/logo/blueieda.gif" >< img  src ="images/logo/htmlcn.gif" >< img  src ="images/logo/fwcn.gif" >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
</ td >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< td  id =demo2  valign =top ></ td >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
</ tr >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
</ table >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
</ div >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_405b18b4b6584ae338e0f6ecaf736533.gifimg_1c53668bcee393edac0d7b3b3daff1ae.gif
< script > img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif
img_33d02437d135341f0800e3d415312ae8.gif
var speed=30
img_33d02437d135341f0800e3d415312ae8.gifdemo2.innerHTML
=demo1.innerHTML
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
function Marquee()img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif
if(demo2.offsetWidth-demo.scrollLeft<=0)
img_33d02437d135341f0800e3d415312ae8.gifdemo.scrollLeft
-=demo1.offsetWidth
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
elseimg_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gifdemo.scrollLeft
++
img_105a1e124122b2abcee4ea8e9f5108f3.gif}

img_105a1e124122b2abcee4ea8e9f5108f3.gif}

img_33d02437d135341f0800e3d415312ae8.gif
var MyMar=setInterval(Marquee,speed)
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gifdemo.onmouseover
=function() img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{clearInterval(MyMar)}
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gifdemo.onmouseout
=function() img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{MyMar=setInterval(Marquee,speed)}
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
</ script >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif


制作向右滚动的效果:
  将上面“制作向左滚动的效果”中的红色字体Js部分替换成:
img_a6339ee3e57d1d52bc7d02b338e15a60.gif < base  href ="http://www.it365cn.com" >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< div  id =demo  style =overflow:hidden;height:33;width:500;background:#214984;color:#ffffff >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< table  align =left  cellpadding =0  cellspace =0  border =0 >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< tr >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< td  id =demo1  valign =top >< img  src ="images/logo_1.gif" >< img  src ="images/logo/flashempire.gif" >< img  src ="images/logo.gif" >< img  src ="images/logo/5dmedia.gif" >< img  src ="images/logo/macromedia.gif" >< img  src ="images/logo/sucaiw.gif" >< img  src ="images/logo/blueieda.gif" >< img  src ="images/logo/htmlcn.gif" >< img  src ="images/logo/fwcn.gif" >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
</ td >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< td  id =demo2  valign =top ></ td >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
</ tr >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
</ table >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
</ div >
img_405b18b4b6584ae338e0f6ecaf736533.gifimg_1c53668bcee393edac0d7b3b3daff1ae.gif
< script > img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif
img_33d02437d135341f0800e3d415312ae8.gif
var speed=30
img_33d02437d135341f0800e3d415312ae8.gifdemo2.innerHTML
=demo1.innerHTML
img_33d02437d135341f0800e3d415312ae8.gifdemo.scrollLeft
=demo.scrollWidth
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
function Marquee()img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif
if(demo.scrollLeft<=0)
img_33d02437d135341f0800e3d415312ae8.gifdemo.scrollLeft
+=demo2.offsetWidth
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
elseimg_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gifdemo.scrollLeft
--
img_105a1e124122b2abcee4ea8e9f5108f3.gif}

img_105a1e124122b2abcee4ea8e9f5108f3.gif}

img_33d02437d135341f0800e3d415312ae8.gif
var MyMar=setInterval(Marquee,speed)
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gifdemo.onmouseover
=function() img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{clearInterval(MyMar)}
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gifdemo.onmouseout
=function() img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{MyMar=setInterval(Marquee,speed)}
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
</ script >
目录
相关文章
|
25天前
|
存储 JavaScript 对象存储
js检测数据类型有那些方法
js检测数据类型有那些方法
133 59
|
2天前
|
JavaScript
js两种移除事件的方法
js两种移除事件的方法
11 2
|
2天前
|
JavaScript 前端开发
JS几种拼接字符串的方法
JS几种拼接字符串的方法
11 1
|
2天前
|
JavaScript 前端开发 索引
JS 删除数组元素( 5种方法 )
JS 删除数组元素( 5种方法 )
9 1
|
3天前
|
JavaScript 前端开发 开发者
【干货拿走】JavaScript中最全的数据类型判断方法!!!!
【干货拿走】JavaScript中最全的数据类型判断方法!!!!
10 1
|
19天前
|
JavaScript 前端开发 API
javaScript中常用的String方法以及注意点总结
本文总结了JavaScript中常用的String对象的方法及其注意事项,包括大小写转换、字符获取、子字符串截取、字符串拼接、去除空格、替换、分割以及查找字符串中字符的索引等操作。提供了每种方法的使用示例代码,帮助理解它们的具体用法和差异。
30 2
|
20天前
|
JavaScript 前端开发
JS之concat方法
本文介绍了JavaScript中`concat`方法的使用,展示了如何利用该方法来合并数组,包括与字符串、数字、对象等类型的拼接,以及使用扩展运算符进行合并的示例。
11 0
JS之concat方法
|
2天前
|
JavaScript 前端开发 安全
JavaScript实现跳转的方法
JavaScript实现跳转的方法
7 0
|
26天前
|
JavaScript 前端开发
JavaScript Array map() 方法
JavaScript Array map() 方法
|
3天前
|
JavaScript 索引
js数组去重的常见方法
js数组去重的常见方法
11 0