网页图片无缝循环滚动html代码

合集下载

图片循环滚动代码(无缝滚动)(分别向上、下、左、右)

图片循环滚动代码(无缝滚动)(分别向上、下、左、右)

图⽚循环滚动代码(⽆缝滚动)(分别向上、下、左、右)向上:程序代码<div id=demo style="overflow:hidden; width:128px; height:300px;"><div id=demo1><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br></div><div id=demo2></div></div><script language="javascript">var speed=30demo2.innerHTML=demo1.innerHTMLfunction Marquee(){if(demo2.offsetTop-demo.scrollTop<=0)demo.scrollTop-=demo1.offsetHeightelse{demo.scrollTop++}}var MyMar=setInterval(Marquee,speed)demo.onmouseover=function() {clearInterval(MyMar)}demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}</script>向下:程序代码<div id=demo style="overflow:hidden; width:128px; height:300px;"><div id=demo1><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br><img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br></div><div id=demo2></div></div><script language="javascript">var speed=30demo2.innerHTML=demo1.innerHTMLdemo.scrollTop=demo.scrollHeightfunction Marquee(){if(demo1.offsetTop-demo.scrollTop>=0)demo.scrollTop+=demo2.offsetHeightelse{demo.scrollTop--}}var MyMar=setInterval(Marquee,speed)demo.onmouseover=function() {clearInterval(MyMar)}demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}</script>向左:程序代码<div id=demo style="overflow:hidden;height:100px;width:300px;"><table align=left cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="gfjs.gif"><img src="bxtt.gif"><img src="bzjd.gif"><img src="gfjs.gif"><img src="bxtt.gif"><imgsrc="bzjd.gif"></td><td id=demo2 valign=top></td></tr></table></div><script>var speed=30demo2.innerHTML=demo1.innerHTMLfunction Marquee(){if(demo2.offsetWidth-demo.scrollLeft<=0)demo.scrollLeft-=demo1.offsetWidthelse{demo.scrollLeft++}}var MyMar=setInterval(Marquee,speed)demo.onmouseover=function() {clearInterval(MyMar)}demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}</script>向右:程序代码<div id=demo style="overflow:hidden;height:100px;width:300px;"><table align=left cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="gfjs.gif"><img src="bxtt.gif"><img src="bzjd.gif"><img src="gfjs.gif"><img src="bxtt.gif"><imgsrc="bzjd.gif"></td><td id=demo2 valign=top></td></tr></table></div><script>var speed=30demo2.innerHTML=demo1.innerHTMLdemo.scrollLeft=demo.scrollWidthfunction Marquee(){if(demo.scrollLeft<=0)demo.scrollLeft+=demo2.offsetWidthelse{demo.scrollLeft--}}var MyMar=setInterval(Marquee,speed)demo.onmouseover=function() {clearInterval(MyMar)}demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}</script>。

Html、js图片轮播代码

Html、js图片轮播代码

Html、js图片轮播代码现在基本上每个网站都有一个自动轮播的banner广告图,在没有任何按钮的情况下,图片在规定的时间内进行自动切换。

下面是html、js 图片轮播代码详情。

代码效果图实例:第一秒:第二秒:第三秒:详细代码如下:Html代码部分:<body><ul class="banner"><li><img src="images/1.jpg"></li><li><img src="images/2.jpg"></li><li><img src="images/3.jpg"></li></ul></body>Css代码部分:<style type="text/css">ul,li{margin:0px;padding:0px}li{list-style:none}.banner{width:630px;height:250px;margin:100px auto;overflow:hidden;cursor:pointer} </style>Javascript代码部分:<script type="text/javascript"src="jquery.js"></script><script type="text/javascript">$(function(){var timer=setInterval(function(){if($(".banner li:last").is(":hidden")){$(".banner li:visible").addClass("on");$(".banner li[class=on]").next().fadeIn("slow");$(".banner li[class=on]").hide().removeClass("on");}else{$(".banner li:last").hide();$(".banner li:first").fadeIn("slow");}},2000)$(".banner li").hover(function(){clearInterval(timer);},function(){timer=setInterval(function(){if($(".banner li:last").is(":hidden")){$(".banner li:visible").addClass("on");$(".banner li[class=on]").next().fadeIn("slow");$(".banner li[class=on]").hide().removeClass("on");}else{$(".banner li:last").hide();$(".banner li:first").fadeIn("slow");}},2000)})})</script>【Jquery.js】是一个jquery库,只要百度一下搜索“jquery”下载这个文件就行。

html图片轮播代码

html图片轮播代码
一、数字键控制代码:
<div style="position:relative; top:-50px; left:240px;">
<a href="javascript:show(1)"><span id="I1" style="width:18px; text-align:left; background:gray">1</span></a>
else
{document.getElementById('pic'+i).style.display='none'; document.getElementById('I'+i).style.backgroundColor='gray'axIndex)
}
for(var i=1;i<(maxIndex+1);i++){
if(i==nowIndex)
{document.getElementById('pic'+nowIndex).style.display=''; document.getElementById('I'+nowIndex).style.backgroundColor='red';}
<table cellpadding="0" cellspacing="0" border="0">
<tr><td id="butong_net_left1" valign="top" align="center">

教你如何实现DIV的图片无缝滚动效果

教你如何实现DIV的图片无缝滚动效果

教你如何实现DIV的图片无缝滚动效果在网站制作和站长进行网站维护的时候,经常会想使用滚动图片来达到某种效果,现在我们来教大家如何实现,下面由洛阳蓝点科技技术员整理发布:先了解一下对象的几个的属性:innerHTML:设置或获取位于对象起始和结束标签内的HTMLscrollHeight: 获取对象的滚动高度。

scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离scrollWidth:获取对象的滚动宽度offsetHeight:获取对象相对于版面或由父坐标offsetParent 属性指定的父坐标的高度offsetLeft:获取对象相对于版面或由offsetParent 属性指定的父坐标的计算左侧位置offsetTop:获取对象相对于版面或由offsetTop 属性指定的父坐标的计算顶端位置offsetWidth:获取对象相对于版面或由父坐标offsetParent 属性指定的父坐标的宽度图片上无缝滚动<style type="text/css"><!--#demo {background: #FFF;overflow:hidden;border: 1px dashed #CCC;height: 100px;text-align: center;float: left;}#demo img {border: 3px solid #F2F2F2;display: block;}--></style>向上滚动<div id="demo"><div id="demo1"><a href="#"><img src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img"_fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a></div><div id="demo2"></div></div><script><!--var speed=10; //数字越大速度越慢var tab=document.getElementById("demo");var tab1=document.getElementById("demo1");var tab2=document.getElementById("demo2");tab2.innerHTML=tab1.innerHTML; //克隆demo1为demo2function Marquee(){if(tab2.offsetTop-tab.scrollTop<=0)//当滚动至demo1与demo2交界时tab.scrollTop-=tab1.offsetHeight //demo跳到最顶端else{tab.scrollTop++}}var MyMar=setInterval(Marquee,speed);tab.onmouseover=function() {clearInterval(MyMar)};//鼠标移上时清除定时器达到滚动停止的目的tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};//鼠标移开时重设定时器--></script>图片下无缝滚动<style type="text/css"><!--#demo {background: #FFF;overflow:hidden;border: 1px dashed #CCC;height: 100px;text-align: center;float: left;}#demo img {border: 3px solid #F2F2F2;display: block;}</style>向下滚动<div id="demo"><div id="demo1"><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a></div><div id="demo2"></div></div><script><!--var speed=10; //数字越大速度越慢var tab=document.getElementById("demo");var tab1=document.getElementById("demo1");var tab2=document.getElementById("demo2");tab2.innerHTML=tab1.innerHTML; //克隆demo1为demo2tab.scrollTop=tab.scrollHeightfunction Marquee(){if(tab1.offsetTop-tab.scrollTop>=0)//当滚动至demo1与demo2交界时tab.scrollTop+=tab2.offsetHeight //demo跳到最顶端else{tab.scrollTop--}}var MyMar=setInterval(Marquee,speed);tab.onmouseover=function() {clearInterval(MyMar)};//鼠标移上时清除定时器达到滚动停止的目的tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};//鼠标移开时重设定时器--></script>图片左无缝滚动<style type="text/css"><!--#demo {background: #FFF;overflow:hidden;border: 1px dashed #CCC;width: 500px;}#demo img {border: 3px solid #F2F2F2;}#indemo {float: left;width: 800%;}#demo1 {float: left;}#demo2 {float: left;}--></style>向左滚动<div id="demo"><div id="indemo"><div id="demo1"><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img"src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a></div><div id="demo2"></div></div></div><script><!--var speed=10; //数字越大速度越慢var tab=document.getElementById("demo");var tab1=document.getElementById("demo1");var tab2=document.getElementById("demo2");tab2.innerHTML=tab1.innerHTML;function Marquee(){if(tab2.offsetWidth-tab.scrollLeft<=0)tab.scrollLeft-=tab1.offsetWidthelse{tab.scrollLeft++;}}var MyMar=setInterval(Marquee,speed);tab.onmouseover=function() {clearInterval(MyMar)};tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};--></script>图片右无缝滚动<style type="text/css"><!--#demo {background: #FFF;overflow:hidden;border: 1px dashed #CCC;width: 500px;}#demo img {border: 3px solid #F2F2F2;}#indemo {float: left;width: 800%;}#demo1 {float: left;}#demo2 {float: left;}--></style>向右滚动<div id="demo"><div id="indemo"><div id="demo1"><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a><a href="#"><img _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" _fcksavedurl=""#"><img" src="/images/logo.jpg" border="0" /></a></div><div id="demo2"></div></div></div><script><!--var speed=10; //数字越大速度越慢var tab=document.getElementById("demo");var tab1=document.getElementById("demo1");var tab2=document.getElementById("demo2");tab2.innerHTML=tab1.innerHTML;function Marquee(){if(tab.scrollLeft<=0)tab.scrollLeft+=tab2.offsetWidthelse{tab.scrollLeft--}}var MyMar=setInterval(Marquee,speed);tab.onmouseover=function() {clearInterval(MyMar)};tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};--></script>本篇文章来源于蓝点科技() 原文出处:/2008/product.asp?i=5&id=297。

网页5张图片轮播代码

网页5张图片轮播代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml"><head><title>pic player</title><script type="text/javascript" src="/jslib/jquery/jquery-1.2.6.js"></script> <script type="text/javascript" src="/jslib/jquery/tween.js"></script></head><style type="text/css">img{border:0;}</style><body><div id="picplayer" style="position:relative;overflow:hidden;width:300px;height:300px;clear:none;border:solid 1px #ccc;">there is a pic-player</div><script>var p = $('#picplayer');var pics1 = [{url:'/online/picPlayer/1.jpg',link:'',time:5000},{url: '/online/picPlayer/2.jpg',link:'',time:4000},{url:'http :///online/picPlayer/3.jpg',link:'',time:6000},{url:'http://im/online/picPlayer/2.jpg',link:'',time:6000},{url:'http://img.jb/online/picPlayer/1.jpg',link:'',time:6000}];initPicPlayer(pics1,p.css('width').split('px')[0],p.css('height').split('px')[0]);////function initPicPlayer(pics,w,h){//选中的图片var selectedItem;//选中的按钮var selectedBtn;//自动播放的idvar playID;//选中图片的索引var selectedIndex;//容器var p = $('#picplayer');p.text('');p.append('<div id="piccontent"></div>');var c = $('#piccontent');for(var i=0;i<pics.length;i++){//添加图片到容器中c.append('<a href="'+pics[i].link+'" target="_blank"><img id="picitem'+i+'" style="display: none;z-index:'+i+'" src="'+pics[i].url+'" /></a>');}//按钮容器,绝对定位在右下角p.append('<div id="picbtnHolder" style="position:absolute;top:'+(h-25)+'px;width:'+w+'px;height:20px;z-index:10000;"></div >');//var btnHolder = $('#picbtnHolder');btnHolder.append('<div id="picbtns" style="float:right; padding-right:1px;"></div>');var btns = $('#picbtns');//for(var i=0;i<pics.length;i++){//增加图片对应的按钮btns.append('<span id="picbtn'+i+'" style="cursor:pointer; border:solid 1px #ccc;background-color:#eee; display:inline-block;"> '+(i+1)+' </span> ');$('#picbtn'+i).data('index',i);$('#picbtn'+i).click(function(event){if(selectedItem.attr('src') == $('#picitem'+$(this).data('index')).attr('src')){return;}setSelectedItem($(this).data('index'));});}btns.append(' ');///setSelectedItem(0);//显示指定的图片indexfunction setSelectedItem(index){selectedIndex = index;clearInterval(playID);//alert(index);if(selectedItem)selectedItem.fadeOut('fast');selectedItem = $('#picitem'+index);selectedItem.fadeIn('slow');//if(selectedBtn){selectedBtn.css('backgroundColor','#eee'); selectedBtn.css('color','#000');}selectedBtn = $('#picbtn'+index); selectedBtn.css('backgroundColor','#000'); selectedBtn.css('color','#fff');//自动播放playID = setInterval(function(){var index = selectedIndex+1;if(index > pics.length-1)index=0; setSelectedItem(index);},pics[index].time);}}</script></body></html>黄色的地方修改显示大小和显示的图片如增加图片可以通过增加var pics1 后面的内容。

html图片无缝滚动代码(向左滚动)

html图片无缝滚动代码(向左滚动)
<div id="_left" style="overflow:hidden;width:810px;">
<table cellpadding="0" cellspacing="0" border="0">
<tr><td id="_left1" valign="top" align="center">
function Marquee3(){
if(_left2.offsetWidth-_left.scrollLeft<=0)
_left.scrollLeft-=_left1.offsetWidth
else{
_left.scrollLeft++
}
}
var MyMar3=setInterval(Marquee3,speed)
_left.onmouseover=function() {clearInterval(MyMar3)}
_left.onmouseout=function() {MyMaห้องสมุดไป่ตู้3=setInterval(Marquee3,speed)}
</script>
<td><a href=""><img src="/logo.gif" border=0></a></td>
<td><a href=""><img src="/logo.gif" border=0></a></td>

网页图片无缝循环滚动html代码

网页图片无缝循环滚动html代码

图片循环滚动代码图片无缝滚动代码先介绍一下它的实现思路:一个设定宽度并且隐藏超出它宽度的内容的容器demo,里面放demo1和demo2,demo1是滚动内容,demo2为demo1的直接克隆,通过不断改变demo1的scrollTop或者scrollLeft达到滚动的目的,当滚动至demo1与demo2的交界处时直接跳回初始位置,因为demo1与demo2一样,所以分不出跳动的瞬间,从而达到“无缝”滚动的目的。

先了解一下对象的几个的属性:innerHTML:设置或获取位于对象起始和结束标签内的 HTMLscrollHeight: 获取对象的滚动高度。

scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离scrollWidth:获取对象的滚动宽度offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度offsetLeft:获取对象相对于版面或由 offsetParent 属性指定的父坐标的计算左侧位置offsetTop:获取对象相对于版面或由 offsetTop 属性指定的父坐标的计算顶端位置offsetWidth:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的宽度向上滚动的代码:<div id=demo style=overflow:hidden;height:400;width:160;background:#214984;color:#ffffff><tab le align=top cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="pic/1.jpg" width="156" height="200" /><br><img src="pic/2.jpg" width="160" height="198" /><br><img src="pic/3.jpg" width="155" height="200" /><br><img src="pic/4.jpg" width="157" height="200" /></td></tr><tr><td id=demo2 valign=top></td></tr></table></div><script>var speed=30demo2.innerHTML=demo1.innerHTML//克隆demo1为demo2function Marquee(){if(demo2.offsetHeight-demo.scrollTop<=0)//当滚动至demo1与demo2交界时demo.scrollTop-=demo1.offsetHeight//demo跳到最顶端else{demo.scrollTop++}}var MyMar=setInterval(Marquee,speed)//设置定时器demo.onmouseover=function() {clearInterval(MyMar)}//鼠标移上时清除定时器达到滚动停止的目的demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}//鼠标移开时重设定时器</script>向下滚动:<div id=demo style=overflow:hidden;height:400;width:160;background:#214984;color:#ffffff><tab le align=top cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="pic/1.jpg" width="156" height="200" /><br><img src="pic/2.jpg" width="160" height="198" /><br><img src="pic/3.jpg" width="155" height="200" /><br><img src="pic/4.jpg" width="157" height="200" /></td></tr><tr><td id=demo2 valign=top></td></tr></table></div><script>var speed=30demo2.innerHTML=demo1.innerHTMLfunction Marquee(){if(demo.scrollTop<=0)demo.scrollTop+=demo2.offsetHeightelse{demo.scrollTop--}}var MyMar=setInterval(Marquee,speed)demo.onmouseover=function() {clearInterval(MyMar)}demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}</script>向左滚动:<div id=demo style=overflow:hidden;height:200;width:500;background:#214984;color:#ffffff><tab le align=left cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="pic/1.jpg" width="156" height="200" /><img src="pic/2.jpg" width="160" height="198" /><img src="pic/3.jpg" width="155" height="200" /><img src="pic/4.jpg" width="157" height="200" /></td><td id=demo2 valign=top></td></tr></table></div> <script>var speed=30demo2.innerHTML=demo1.innerHTMLfunction Marquee(){if(demo2.offsetWidth-demo.scrollLeft<=0)demo.scrollLeft-=demo1.offsetWidthelse{demo.scrollLeft++}}var MyMar=setInterval(Marquee,speed)demo.onmouseover=function() {clearInterval(MyMar)}demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}</script>向右滚动:<div id=demo style=overflow:hidden;height:200;width:500;background:#214984;color:#ffffff><tab le align=left cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="pic/1.jpg" width="156" height="200" /><img src="pic/2.jpg" width="160" height="198" /><img src="pic/3.jpg" width="155" height="200" /><img src="pic/4.jpg" width="157" height="200" /></td><td id=demo2 valign=top></td></tr></table></div> <script>var speed=30demo2.innerHTML=demo1.innerHTMLfunction Marquee(){if(demo.scrollLeft<=0)demo.scrollLeft+=demo2.offsetWidthelse{demo.scrollLeft--}}var MyMar=setInterval(Marquee,speed)demo.onmouseover=function() {clearInterval(MyMar)}demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}</script><!--无缝向左循环代码开始--><div id="mhmove" style="overflow:hidden;width:800px;margin:0 auto 0;"> <table width="800px" border="0" cellspacing="0" cellpadding="0"> <tr><td width="800px" id="mhmove1"><table width="800px" border="0" cellpadding="0" cellspacing="0"><tr><td width="166" align="center"><img src="tupian/gumushi1538.4m.jpg"width="166" height="117" border="0" usemap="#Map2" /></td><td width="166" align="center"> <img src="tupian/tupian1/pingchuanghe7[1].jpg" width="166" height="117" border="0" usemap="#Map"/></td><td width="166" align="center"><img src="tupian/tupian1/1[2].jpg" width="166" height="117" border="0" usemap="#Map3" /></td><td width="166" align="center"><img src="tupian/tupian1/6[1].jpg" width="166" height="117" border="0" usemap="#Map4" /></td><td width="172" align="center"><img src="tupian/tupian1/92[1].jpg" width="166" height="117" border="0" usemap="#Map5" /></td><td width="172" align="center"><img src="tupian/dujuan_da2.jpg" width="166" height="117" border="0" usemap="#Map6" /></td></tr></table></td><td width="50" id="mhmove2">&nbsp;</td></tr></table></div><script>var speed=40 ;mhmove2.innerHTML=mhmove1.innerHTML;function Marquee3(){if(mhmove2.offsetWidth-mhmove.scrollLeft<=0)mhmove.scrollLeft-=mhmove1.offsetWidth;else{mhmove.scrollLeft++;}}function Marquee4(){if(mhmove2.offsetHeight-mhmove.scrollTop<=0)mhmove.scrollTop-=mhmove1.offsetHeight;else{mhmove.scrollTop++;}}var MyMar2=setInterval(Marquee3,speed);mhmove.onmouseover=function() {clearInterval(MyMar2)}mhmove.onmouseout=function(){MyMar2=setInterval(Marquee3,speed)}</script><!--无缝循环代码结束-->。

网站首页图片轮转代码,很好用

网站首页图片轮转代码,很好用

网站首页图片轮转代码,很好用网站首页图片轮转代码聪明的朋友可以把它用到自己的网店里面做装修,非常好用的代码如下,注释的地方需要改变即可<SCRIPT><!--以下分别是,宽,高,图片数,间隔时间-->var widths =500;var heights =410;var counts =6;var times = 4000;<!--以下12行代码中的如:/07.jpg ,改成自己需要的图片URL 即可,下面一部分的链接换成商品的地址即可-->img1=new Image ();img1.src='/07.jpg';img2=new Image ();img2.src='/06.jpg';img3=new Image ();img3.src='/05.jpg';img4=new Image ();img4.src='/04.jpg';img5=new Image ();img5.src='/03.jpg';img6=new Image ();img6.src='/02.jpg';url1=new Image ();url1.src='/';url2=new Image ();url2.src='/';url3=new Image ();url3.src='/';url4=new Image ();url4.src='/';url5=new Image ();url5.src='/';url6=new Image ();url6.src='/';//联盟商贸技术支持友情提供var nn=1;var key=0;function change_img(){if(key==0){key=1;}else if(document.all){document.getElementByIdx("pic").filters[0].Apply();document.getElementByIdx("pic").filters[0].Play(duration=2);}eval_r('document.getElementByIdx("pic").src=img'+nn+'.src' );eval_r('document.getElementByIdx("url").href=url'+nn+'.src' );for (var i=1;i<=counts;i++){document.getElementByIdx("xxjdjj"+i).className='axx';}document.getElementByIdx("xxjdjj"+nn).className='bxx';nn++;if(nn>counts){nn=1;}tt=setTimeout('change_img()',4000);}function changeimg(n){nn=n;window.clearInterval(tt);change_img();}document.write('<style>');document.write('.axx{padding:1px 7px;border-left:#cccccc 1px solid;}');document.write('a.axx:link,a.axx:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#666;}');document.write('a.axx:active,a.axx:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#999;}');document.write('.bxx{padding:1px 7px;border-left:#cccccc 1px solid;}');document.write('a.bxx:link,a.bxx:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}');document.write('a.bxx:active,a.bxx:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}');document.write('</style>');document.write('<divstyle="width:'+widths+'px;height:'+heights+'px;overflow:hidde n;text-overflow:clip;">');document.write('<div><a id="url" target="_blank"><img id="pic"style="border:0px;filter:progid:dximagetransform.microsoft.wip e(gradientsize=1.0,wipestyle=4, motion=forward)" width='+widths+' height='+heights+' /></a></div>');document.write('<divstyle="filter:alpha(style=1,opacity=10,finishOpacity=80);backgr ound: #888888;width:100%-2px;text-align:right;top:-12px;position:relative;margin:1px;height:12px;padding:0px;marg in:0px;border:0px;">');for(var i=1;i<counts+1;i++){document.write('<a href="javascript:changeimg('+i+');" id="xxjdjj'+i+'" class="axx" target="_self">'+i+'</a>');}document.write('</div></div>');change_img();</SCRIPT>。

关于网页上图片无缝滚动的一些思路

关于网页上图片无缝滚动的一些思路

关于网页上图片无缝滚动的一些思路从现在的一些常见网站上,无缝滚动的例子用得非常普遍,可以说很常见,也比较实用,下面我们就来简单看看,具体的一些想法怎么实现的:先简单来看一下原理:首先我们看到网页上一组图片不停滚动,一次循环之后又从第一张开始,其实简单的思路是:我们设置两组图片,当第一组图片滚动到结尾时,对应的第一组图片又瞬间拉回到起始位置。

当图片向另外一个方向滚动时,当后面一组图片滚动到结尾时:也是瞬间拉回到开头。

下面我们简单来看一下代码:<!DOCTYPE html><html><head><meta charset="utf-8"><title></title><style type="text/css">*{ margin: 0;padding: 0; } //页面的简单布局#div1{ width: 600px;height: 120px;border: 1px solid #ccc; margin: 10px auto;position: relative;overflow:hidden;} #div1 ul{ list-style-type: none;height:120px;position: absolute;left: 0;top: 0; }#div1 ul li{float: left;width: 100px;height: 100px;padding: 10px;}</style><script type="text/javascript">window.onload = function(){var oUl = document.getElementById("ul1");var oLi = oUl.getElementsByTagName('li');var timer = null; //声明一个接受定时器返回值的变量,初始值为空var iSpeed = -2;oUl.style.width = (oLi.length)*oLi[0].offsetWidth+'px'; //动态的添加UL的长度,这样可以适应布局timer=setInterval(function(){if(oUl.offsetLeft<-oUl.offsetWidth/2){ //首先向左滚动,如果滚到一半,此时left应该是-oUl.offsetWidth/2,我们就将他拉回来到起始的位置oUl.style.left = 0+'px';}if(oUl.offsetLeft>0){oUl.style.left = -oUl.offsetWidth/2+'px'; //同理向右跑到一半,原理一样,就拉回来}oUl.style.left = oUl.offsetLeft+iSpeed+'px';},30);oUl.onmouseover = function(){ //鼠标移入到图片上时,就停止运动clearInterval(timer);}oUl.onmouseout = function(){timer=setInterval(function(){if(oUl.offsetLeft<-oUl.offsetWidth/2){ //鼠标移出时,又开始运动oUl.style.left = 0+'px';}if(oUl.offsetLeft>0){oUl.style.left = -oUl.offsetWidth/2+'px'; //向右跑到一半,就拉回来}oUl.style.left = oUl.offsetLeft+iSpeed+'px';},30);}}</script></head><body><div id="div1"><ul id="ul1"> //这里我们设置了两组图片<li><img src="img/宁静的海1.jpg"></li><li><img src="img/就这样1.jpg"></li><li><img src="img/宁静1.jpg"></li><li><img src="img/bus1.jpg"></li><li><img src="img/cry1.jpg"></li><li><img src="img/宁静的海1.jpg"></li><li><img src="img/就这样1.jpg"></li><li><img src="img/宁静1.jpg"></li><li><img src="img/bus1.jpg"></li><li><img src="img/cry1.jpg"></li></ul></div></body></html>当然我么可以简化代码:function startMove(){timer=setInterval(function(){if(oUl.offsetLeft<-oUl.offsetWidth/2){ //鼠标移出时,又开始运动oUl.style.left = 0+'px';}if(oUl.offsetLeft>0){oUl.style.left = -oUl.offsetWidth/2+'px'; //向右跑到一半,就拉回来}oUl.style.left = oUl.offsetLeft+iSpeed+'px';},30);}将这段重复代码写成一个函数,后面直接调用即可。

html无缝轮播图完整代码

html无缝轮播图完整代码

html⽆缝轮播图完整代码<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>轮播图⽆缝滚动</title><style type="text/css">*{ padding:0; margin:0; list-style:none; border:0;}.all{width:500px;height:200px;padding:7px;border:1px solid #ccc;margin:100px auto;position:relative;}.screen{width:500px;height:200px;overflow:hidden;position:relative;}.screen li{ width:500px; height:200px; overflow:hidden; float:left;}.screen ul{ position:absolute; left:0; top:0px; width:3000px;}.all ol{ position:absolute; right:10px; bottom:10px; line-height:20px; text-align:center;}.all ol li{ float:left; width:20px; height:20px; background:#fff; border:1px solid #ccc; margin-left:10px; cursor:pointer;}.all ol li.current{ background:yellow;}/*#arr {display: none;}*/#arr span{ width:40px; height:40px; position:absolute; left:5px; top:50%; margin-top:-20px; background:#000; cursor:pointer; line-height:40px; text-align:center; font-weight:bold; font-family:'⿊体'; font-size:30px; color:#fff; opacity:0.3; #arr #right{right:5px; left:auto;}</style></head><body><div class="all" id='all'><div class="screen" id="screen"><ul id="ul"><li><img src="images/1.jpg" width="500" height="200"/></li><li><img src="images/2.jpg" width="500" height="200"/></li><li><img src="images/3.jpg" width="500" height="200"/></li><li><img src="images/4.jpg" width="500" height="200"/></li><li><img src="images/5.jpg" width="500" height="200"/></li></ul><ol></ol><div id="arr"><span id="left"><</span><span id="right">></span></div></div></div></body></html><script>//需求:⽆缝轮播图//步骤://1.⽼三步。

平面网页滚动图片代码

平面网页滚动图片代码

<nobr><div id="marqueediv8" style="width:831px;height:120px;overflow:hidden; "> <img src="images/1.jpg" width="150" height="120" border="0"/> <img src="images/2.jpg" width="150" height="120" border="0" /> <img src="images/3.jpg" width="150" height="120" border="0"/> <img src="images/4.jpg" width="150" height="120"border="0" /> <img src="images/5.jpg" width="150" height="120" border="0"/> <img src="images/6.jpg" width="150" height="120"border="0" /> <img src="images/7.jpg" width="150" height="120" border="0"/> <img src="images/8.jpg" width="150" height="120"border="0" /> <img src="images/9.jpg" width="150" height="120" border="0"/> <img src="images/10.jpg" width="150" height="120"border="0" /> <img src="images/11.jpg" width="150" height="120" border="0"/> <img src="images/12.jpg" width="150" height="120"border="0" /> <img src="images/13.jpg" width="150" height="120" border="0"/> <img src="images/14.jpg" width="150" height="120" border="0"/> </div></nobr><script>window.onload=function(){new Marquee("marqueediv8", //容器ID<br />2, //向上滚动(0向上1向下2向左3向右)<br />1, //滚动的步长<br />831, //容器可视宽度<br />120, //容器可视高度<br />30, //定时器数值越小,滚动的速度越快(1000=1秒,建议不小于20)<br />0, //间歇停顿时间(0为不停顿,1000=1秒)<br />0, //开始时的等待时间(0为不等待,1000=1秒)<br />0//间歇滚动间距(可选)<br />);};</script><script>function Marquee(){this.ID=document.getElementById(arguments[0]);this.Direction=arguments[1];this.Step=arguments[2];this.Width=arguments[3];this.Height=arguments[4];this.Timer=arguments[5];this.WaitTime=arguments[6];this.StopTime=arguments[7];if(arguments[8]){this.ScrollStep=arguments[8];}else{this.ScrollStep=this.Direction>1?this.Width: this.Height;}this.CTL=this.StartID=this.Stop=this.MouseOver=0;this.ID.style.overflowX=this.ID.style.overflowY="hidden";this.ID.noWrap=true;this.ID.style.width=this.Width;this.ID.style.height=this.Height;this.ClientScroll=this.Direction>1?this.ID.scrollWidth:this.ID.scrollHeight;this.ID.innerHTML+=this.ID.innerHTML;this.Start(this,this.Timer,this.WaitTime,this.StopTime);}Marquee.prototype.Start=function(msobj,timer,waittime,stoptime){msobj.StartID=function(){msobj.Scroll();}msobj.Continue=function(){if(msobj.MouseOver==1){setTimeout(msobj.Continue,waittime);}else{clearInterval(msobj.TimerID); msobj.CTL=msobj.Stop=0; msobj.TimerID=setInterval(msobj.StartID,timer);}}msobj.Pause=function(){msobj.Stop=1; clearInterval(msobj.TimerID); setTimeout(msobj.Continue,waittime);}msobj.Begin=function(){msobj.TimerID=setInterval(msobj.StartID,timer);msobj.ID.onmouseover=function(){msobj.MouseOver=1; clearInterval(msobj.TimerID);} msobj.ID.onmouseout=function(){msobj.MouseOver=0;if(msobj.Stop==0){clearInterval(msobj.TimerID);msobj.TimerID=setInterval(msobj.StartID,timer);}}}setTimeout(msobj.Begin,stoptime);}Marquee.prototype.Scroll=function(){switch(this.Direction){case 0:this.CTL+=this.Step;if(this.CTL>=this.ScrollStep&&this.WaitTime>0){this.ID.scrollTop+=this.ScrollStep+this.Step-th is.CTL; this.Pause(); return;}else{if(this.ID.scrollTop>=this.ClientScroll) this.ID.scrollTop-=this.ClientScroll; this.ID.scrollTop+=this.Step;}break;case 1:this.CTL+=this.Step;if(this.CTL>=this.ScrollStep&&this.WaitTime>0){this.ID.scrollTop-=this.ScrollStep+this.Step-thi s.CTL; this.Pause(); return;}else{if(this.ID.scrollTop<=0) this.ID.scrollTop+=this.ClientScroll; this.ID.scrollTop-=this.Step;}break;case 2:this.CTL+=this.Step;if(this.CTL>=this.ScrollStep&&this.WaitTime>0){this.ID.scrollLeft+=this.ScrollStep+this.Step-th is.CTL; this.Pause(); return;}else{if(this.ID.scrollLeft>=this.ClientScroll) this.ID.scrollLeft-=this.ClientScroll; this.ID.scrollLeft+=this.Step;}break;case 3:this.CTL+=this.Step;if(this.CTL>=this.ScrollStep&&this.WaitTime>0){this.ID.scrollLeft-=this.ScrollStep+this.Step-th is.CTL; this.Pause(); return;}else{if(this.ID.scrollLeft<=0) this.ID.scrollLeft+=this.ClientScroll; this.ID.scrollLeft-=this.Step;}break;}}</script>。

原生Js实现的简单无缝滚动轮播图的示例代码

原生Js实现的简单无缝滚动轮播图的示例代码

原⽣Js实现的简单⽆缝滚动轮播图的⽰例代码 简单⽆缝滚动轮播图存在很多漏洞,就是后期增加图⽚时会很不⽅便,需要改动的地⽅也很多,耦合性也很强,只适⽤于⼀部分程序,所以我们可以通过改动图⽚结构和计算折算点的⽅式,升级代码。

原简单的滚动轮播代码<html><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>*{margin: 0;padding: 0;}.scroll{position: relative;width: 830px;/*展⽰宽度展⽰4个图+3个边框=830*/height: 130px;border: 10px solid rgb(15, 15, 15);margin: 100px auto;overflow: hidden;}.scroll ul{position: absolute;width: 5000px;/*ul能存下所有li的宽*/height: 130px;top: 0;left: 0;}.scroll ul li{float: left;width: 200px;height: 130px;margin-right: 10px;overflow: hidden;}</style></head><body><div id="scroll" class="scroll"><ul id="munit"><li><img src="../BOM/shuzi/3.png" alt=""></li><li><img src="../BOM/shuzi/4.png" alt=""></li><li><img src="../BOM/shuzi/5.png" alt=""></li><li><img src="../BOM/shuzi/6.png" alt=""></li><li><img src="../BOM/shuzi/7.png" alt=""></li><li><img src="../BOM/shuzi/8.png" alt=""></li><li><img src="../BOM/shuzi/9.png" alt=""></li><li><img src="../BOM/shuzi/3.png" alt=""></li><li><img src="../BOM/shuzi/4.png" alt=""></li><li><img src="../BOM/shuzi/5.png" alt=""></li><li><img src="../BOM/shuzi/6.png" alt=""></li><li><img src="../BOM/shuzi/7.png" alt=""></li><li><img src="../BOM/shuzi/8.png" alt=""></li><li><img src="../BOM/shuzi/9.png" alt=""></li></ul></div><script>//获取元素var scroll = document.getElementById("scroll");var munit = document.getElementById("munit");var li = munit.children;// 进⾏滚动var nowLeft = 0;//要找到ul元素运动的折返点var back = -1470;//图和边框是li的宽度,展⽰的有4张图,所以折返点就是1260//定时器var timer = setInterval(run,20);// ⿏标移上scroll停⽌scroll.onmouseover = function(){clearInterval(timer);}// 移开轮播scroll.onmouseout = function(){timer = setInterval(run,20);}//运动函数function run(){nowLeft -= 2;//判断是否⾛到了折返点,⾛到了,则瞬间切换到0位置if(nowLeft <= back){nowLeft = 0;}munit.style.left = nowLeft + "px";}</script></body></html> 在<div id="scroll">结构给ul新增的⼀个⽗级div,这样之后添加图⽚,后期通过获取ul宽度就可以了计算折算点 1、折返点计算需要通过Js⾃动计算 var back = -munit.offsetWidth;//元素左移,值为负数 2、⾃动⽣成另⼀组对应的图⽚结构 li munit.innerHTML = munit.innerHTML + munit.innerHTML;//这样就会增加⼀组li标签,后期增加图⽚也会随之增加修改部分代码,css改写部分:/*给ul新增的⼀个⽗级div,这样添加图⽚后期获取ul宽度就可以了 */.scroll .inner{position: relative;width: 5000px;}.scroll ul{position: absolute;height: 130px;top: 0;left: 0;list-style: none;body改写部分:<body><div id="scroll" class="scroll"><div class="inner"><ul id="munit"><li><img src="../BOM/shuzi/3.png" alt=""></li><li><img src="../BOM/shuzi/4.png" alt=""></li><li><img src="../BOM/shuzi/5.png" alt=""></li><li><img src="../BOM/shuzi/6.png" alt=""></li><li><img src="../BOM/shuzi/7.png" alt=""></li><li><img src="../BOM/shuzi/8.png" alt=""></li><li><img src="../BOM/shuzi/9.png" alt=""></li><li><img src="../BOM/shuzi/10.png" alt=""></li></ul></div></div>JS改写部分:<script>//获取元素var scroll = document.getElementById("scroll");var munit = document.getElementById("munit");//改写部分//1 折返点计算需要通过Js⾃动计算var back = -munit.offsetWidth;//元素左移,值为负数//2 ⾃动⽣成另⼀组对应的图⽚结构 limunit.innerHTML = munit.innerHTML + munit.innerHTML;// 进⾏滚动var nowLeft = 0;//定时器var timer = setInterval(run,20);// ⿏标移上scroll停⽌scroll.onmouseover = function(){clearInterval(timer);}// 移开轮播scroll.onmouseout = function(){timer = setInterval(run,20);}//运动函数function run(){nowLeft -= 1;//判断是否⾛到了折返点,⾛到了,则瞬间切换到0位置if(nowLeft <= back){nowLeft = 0;}munit.style.left = nowLeft + "px";}</script></body></html>这样的代码耦合性低,也适合任意个数的li、任意⼤⼩的图⽚的加⼊以上就是原⽣Js 实现的简单⽆缝滚动轮播图的⽰例代码的详细内容,更多关于Js 实现的简单⽆缝滚动轮播图的资料请关注其它相关⽂章!。

Html网页图片滚动代码

Html网页图片滚动代码

Html网页图片滚动代码<!--下面是向上滚动代码--><div id=butong_net_top style=overflow:hidden;height:100;width:90;><div id=butong_net_top1><img src="插入需要滚动的图片"><img src="插入需要滚动的图片"><img src="插入需要滚动的图片"><img src="插入需要滚动的图片"><img src="插入需要滚动的图片"></div><div id=butong_net_top2></div></div><script>var speed=30butong_net_top2.innerHTML=butong_net_top1.innerHTML //克隆butong_net_top1为butong_net_top2function Marquee1(){//当滚动至butong_net_top1与butong_net_top2交界时if(butong_net_top2.offsetTop-butong_net_top.scrollTop<=0)&<60;&<60;butong_net_top.scrollTop-=butong_net_top1.offsetHeight //butong_net_top跳到最顶端else{butong_net_top.scrollTop++;}}var MyMar1=setInterval(Marquee1,speed)//设置定时器//鼠标移上时清除定时器达到滚动停止的目的butong_net_top.onmouseover=function() {clearInterval(MyMar1)}//鼠标移开时重设定时器butong_net_top.onmouseout=function(){MyMar1=setInterval(Marquee1,speed)}</script><!--向上滚动代码结束--><br><!--下面是向下滚动代码--><div id=butong_net_bottom style=overflow:hidden;height:100;width:90;><div id=butong_net_bottom1><img src="插入需要滚动的图片"><img src="插入需要滚动的图片"><img src="插入需要滚动的图片"><img src="插入需要滚动的图片"><img src="插入需要滚动的图片"></div><div id=butong_net_bottom2></div></div><script>var speed=30butong_net_bottom2.innerHTML=butong_net_bottom1.innerHTMLbutong_net_bottom.scrollTop=butong_net_bottom.scrollHeightfunction Marquee2(){if(butong_net_bottom1.offsetTop-butong_net_bottom.scrollTop>=0)butong_net_bottom.scrollTop+=butong_net_bottom2.offsetHeightelse{butong_net_bottom.scrollTop--}}var MyMar2=setInterval(Marquee2,speed)butong_net_bottom.onmouseover=function() {clearInterval(MyMar2)}butong_net_bottom.onmouseout=function() {MyMar2=setInterval(Marquee2,speed)} </script><!--向下滚动代码结束--><br><!--下面是向左滚动代码--><div id="butong_net_left" style="overflow:hidden;width:500px;"><table cellpadding="0" cellspacing="0" border="0"><tr><td id="butong_net_left1" valign="top" align="center"><table cellpadding="2" cellspacing="0" border="0"><tr align="center"><td><img src="<img src="插入需要滚动的图片"></td><td><img src="插入需要滚动的图片"></td><td><img src="插入需要滚动的图片"></td><td><img src="插入需要滚动的图片"></td><td><img src="插入需要滚动的图片"></td></tr></table></td><td id="butong_net_left2" valign="top"></td></tr></table></div><script>var speed=30//速度数值越大速度越慢butong_net_left2.innerHTML=butong_net_left1.innerHTMLfunction Marquee3(){if(butong_net_left2.offsetWidth-butong_net_left.scrollLeft<=0)butong_net_left.scrollLeft-=butong_net_left1.offsetWidthelse{butong_net_left.scrollLeft++}}var MyMar3=setInterval(Marquee3,speed)butong_net_left.onmouseover=function() {clearInterval(MyMar3)}butong_net_left.onmouseout=function() {MyMar3=setInterval(Marquee3,speed)} </script><!--向左滚动代码结束--><br><!--下面是向右滚动代码--><div id="butong_net_right" style="overflow:hidden;width:500px;"><table cellpadding="0" cellspacing="0" border="0"><tr><td id="butong_net_right1" valign="top" align="center"><table cellpadding="2" cellspacing="0" border="0"><tr align="center"><td><img src="插入需要滚动的图片"></td><td><img src="插入需要滚动的图片"></td><td><img src="插入需要滚动的图片"></td><td><img src="插入需要滚动的图片"></td><td><img src="插入需要滚动的图片"></td></tr></table></td><td id="butong_net_right2" valign="top"></td></tr></table></div><script>var speed=30//速度数值越大速度越慢butong_net_right2.innerHTML=butong_net_right1.innerHTMLfunction Marquee4(){if(butong_net_right.scrollLeft<=0)butong_net_right.scrollLeft+=butong_net_right2.offsetWidthelse{butong_net_right.scrollLeft--}}var MyMar4=setInterval(Marquee4,speed)butong_net_right.onmouseover=function() {clearInterval(MyMar4)}butong_net_right.onmouseout=function() {MyMar4=setInterval(Marquee4,speed)} </script><!--向右滚动代码结束-->。

不间断滚动图片网页制作源码

不间断滚动图片网页制作源码

<div style="WIDTH: 740px; OVERFLOW: hidden; align: center" id=demo> <table border=0 cellSpacing=0 cellPadding=0><tbody><tr><td id=marquePic1 vAlign=top>{#modCpPic#} </td><td id=marquePic2 vAlign=top></td></tr></tbody></table></div><script type=text/javascript>var speed=30marquePic2.innerHTML=marquePic1.innerHTMLfunction Marquee(){if(demo.scrollLeft>=marquePic1.scrollWidth){demo.scrollLeft=0}else{demo.scrollLeft++}}var MyMar=setInterval(Marquee,speed) //每隔0.03秒调用一次函数demo.onmouseover=function() {clearInterval(MyMar)}demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}</script>innerHTML是inner里的HTML内容object.scrollLeft和object.offsetWidth 是什么意思呀scrollLeft: 获取 object 这个对象的左边界和窗口中目前可见内容的最左端之间的距离offsetWidth: object 对象自身的绝对宽度,不包括因 overflow 而未显示的部分,也就是其实际占据的宽度,整型,单位像素setInterval() 方法会不停地调用函数,直到 clearInterval() 被调用或窗口被关闭。

网页图片轮番显示代码

网页图片轮番显示代码

就像图上一样有 1 2 3 4的代码向左转|向右转提问者采纳2010-03-12 15:55html 代码:<ul><li id="h1"><ahref="javascript:void(0);"><span>1</span></a></li><li id="h2"><ahref="javascript:void(0);"><span>2</span></a></li><li id="h3"><ahref="javascript:void(0);"><span>3</span></a></li><li id="h4"><ahref="javascript:void(0);"><span>4</span></a></li><li id="h5"><ahref="javascript:void(0);"><span>5</span></a></li></ul><div id="h1_body"></div><div id="h2_body"></div><div id="h3_body"></div><div id="h4_body"></div><div id="h5_body"></div></div>js代码:var p_idx=0;function Photo(path,title,url){this.Path=path;this.Title=title;this.URL=url;}var photos=[new Photo('SpeakerPhoto/123.jpg','Liu Changchun',213.aspx'),""];//图片用,分割$(function(){GetPhoto(0,4,$("#h1_body"));GetPhoto(4,4,$("#h2_body"));GetPhoto(8,4,$("#h3_body"));GetPhoto(12,4,$("#h4_body"));GetPhoto(16,2,$("#h5_body"));});function GetPhoto(inx,num,box){for(var i=0;i<num;i++){$(box).append('<a href="'+photos[inx].URL+'"><imgsrc="'+photos[inx].Path+'" title="'+photos[inx].Title+'" /></a>');inx++;}}function GetSinglePhoto(inx){document.write('<img src="'+photos[inx].Path+'"title="'+photos[inx].Title+'" />');}。

HTML中图片连续滚动

HTML中图片连续滚动

HTML中图⽚连续滚动<!DOCTYPE html><html><head><meta charset="utf-8"/><title></title><style type="text/css">*{margin: 0;padding: 0;}div{margin: 100px auto;width: 600px;height: 200px;border:1px solid black;overflow: hidden;}ul{width: 2000px;height: 200px;background: darkgray;animation:change 10s linear 0s infinite normal; /*动画元素,持续时间,速度,延迟时间,重复次数,是否往返*/ }ul:hover{animation-play-state: paused;}ul:hover li{opacity: 0.5; /*透明度,显⽰⽗元素颜⾊*/}ul li:hover{opacity: 1;}ul li{width: 300px;height: 200px;list-style: none;float: left;border:1px solid black;background-color: brown;box-sizing: border-box;}@keyframes change{from{margin-left: 0;}to{margin-left:-1200px ;}}</style></head><body><div><ul><li><img src=""/>1</li><li><img src=""/>2</li><li><img src=""/>3</li><li><img src=""/>4</li><li><img src=""/>1</li><li><img src=""/>2</li></ul></div></body></html>注:img标签中最后两个图⽚必须和第⼀,⼆相同,从⽽做到动画⽆缝衔接。

js实现图片无缝循环轮播

js实现图片无缝循环轮播

js实现图⽚⽆缝循环轮播本⽂实例为⼤家分享了js实现图⽚⽆缝循环轮播的具体代码,供⼤家参考,具体内容如下代码如下<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Document</title><style>#container{overflow:hidden;width:400px;height:300px;margin:auto;}#front,#container{display:flex;flex-direction:row;}#container img{width:400px;height:300px;}</style></head><body><div id="container"><div id="front"><img src="k2.jpg" alt=""><img src="k1.jpg" alt="" ><img src="k3.jpg" alt=""><img src="k4.jpg" alt=""></div><div id="back"><img src="k5.jpg" alt=""></div></div></body><script>front.style="position:relative;left:0px;";back.style="position:relative;left:0px;";setInterval(moveimg,100);var fleft,bleft;function moveimg(){fleft = parseInt(front.style.left);bleft = parseInt(back.style.left);if(fleft == -1600){front.style.left = 400+"px";fleft = parseInt(front.style.left);}if(bleft == -2000) {back.style.left = 0+"px";bleft = parseInt(back.style.left);}front.style.left = (fleft-10)+"px";back.style.left = (bleft-10)+"px";}</script></html>更多关于轮播图效果的专题,请点击下⽅链接查看学习以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

<td width="166" align="center"> <img src="tupian/tupian1/pingchuanghe7[1].jpg" width="166" height="117" border="0" usemap="#Map"/></td>
<td width="166" align="center"><img src="tupian/tupian1/1[2].jpg" width="166" height="117" border="0" usemap="#Map3" /></td>
图片循环滚动代码
图片无缝滚动代码
先介绍一下它的实现思路:一个设定宽度并且隐藏超出它宽度的内容的容器demo,里面放demo1和demo2,demo1是滚动内容,demo2为demo1的直接克隆,通过不断改变demo1的scrollTop或者scrollLeft达到滚动的目的,当滚动至demo1与demo2的交界处时直接跳回初始位置,因为demo1与demo2一样,所以分不出跳动的瞬间,从而达到“无缝”滚动的目的。
</script>
向右滚动:
<div id=demo style=overflow:hidden;height:200;width:500;background:#214984;color:#ffffff><table align=left cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="pic/1.jpg" width="156" height="200" /><img src="pic/2.jpg" width="160" height="198" /><img src="pic/3.jpg" width="155" height="200" /><img src="pic/4.jpg" width="157" height="200" /></td><td id=demo2 valign=top></td></tr></table></div>
<script>
var speed=30
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo.scrollTop<=0)
demo.scrollTop+=demo2.offsetHeight
else{
demo.scrollTop--
</table></td>
<td width="50" id="mhmove2">&nbsp;</td>
</tr>
</table>
</div>
<script>
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetLeft:获取对象相对于版面或由 offsetParent 属性指定的父坐标的计算左侧位置
offsetTop:获取对象相对于版面或由 offsetTop 属性指定的父坐标的计算顶端位置
demo.scrollTop-=demo1.offsetHeight//demo跳到最顶端
else{
demo.scrollTop++
}
}
var MyMar=setInterval(Marquee,speed)//设置定时器
demo.onmouseover=function() {clearInterval(MyMar)}//鼠标移上时清除定时器达到滚动停止的目的
<script>
var speed=30
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
offsetWidth:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的宽度
向上滚动的代码:
<div id=demo style=overflow:hidden;height:400;width:160;background:#214984;color:#ffffff><table align=top cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="pic/1.jpg" width="156" height="200" /><br><img src="pic/2.jpg" width="160" height="198" /><br><img src="pic/3.jpg" width="155" height="200" /><b34; width="157" height="200" /></td></tr><tr><td id=demo2 valign=top></td></tr></table></div>
<td width="172" align="center"><img src="tupian/dujuan_da2.jpg" width="166" height="117" border="0" usemap="#Map6" /></td>
</tr>
</script>
<!--无缝向左循环代码开始-->
<div id="mhmove" style="overflow:hidden;width:800px;margin:0 auto 0;">
<table width="800px" border="0" cellspacing="0" cellpadding="0">
<script>
var speed=30
demo2.innerHTML=demo1.innerHTML//克隆demo1为demo2
function Marquee(){
if(demo2.offsetHeight-demo.scrollTop<=0)//当滚动至demo1与demo2交界时
先了解一下对象的几个的属性:
innerHTML:设置或获取位于对象起始和结束标签内的 HTML
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
向左滚动:
<div id=demo style=overflow:hidden;height:200;width:500;background:#214984;color:#ffffff><table align=left cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="pic/1.jpg" width="156" height="200" /><img src="pic/2.jpg" width="160" height="198" /><img src="pic/3.jpg" width="155" height="200" /><img src="pic/4.jpg" width="157" height="200" /></td><td id=demo2 valign=top></td></tr></table></div>
相关文档
最新文档