① JavaScript里面怎么让图片实现无缝横向滚动效果!!!
先了解一下对象的几个的属性: innerHTML:设置或获取位于对象起始和结束标签内的 HTML scrollHeight: 获取对象的滚动高度。 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=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" 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为demo2 function 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 src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" 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为demo2 tab.scrollTop=tab.scrollHeight function 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 src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" 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.offsetWidth else{ 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 src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" border="0" /></a> <a href="#"><img src=" http://www.fu80.com/other/link/Clear_logo.gif" 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.offsetWidth else{ tab.scrollLeft-- } } var MyMar=setInterval(Marquee,speed); tab.onmouseover=function() {clearInterval(MyMar)}; tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)}; --> </script>
② 【HTML】如何实现无缝循环的图片滚动效果
网站中,有时为了更好的利用有限的页面空间展示更多的内容,也为了丰富网站页面自身的表现样式,我们往往会用到图片滚动的效果。想要实现这种效果,只需要在想要显示的表格或网页中加入以下代码即可实现: <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 height="150" alt="" width="200" src="/lazysite/user_space/7788/CIMG0056_缩小大小.JPG" /> <img height="150" alt="" width="200" src="/lazysite/user_space/7788/CIMG0053_缩小大小.JPG" /> <img height="150" alt="" width="200" src="/lazysite/user_space/7788/CIMG0054_缩小大小.JPG" /> <img height="150" alt="" width="200" src="/lazysite/user_space/7788/CIMG0058_缩小大小.JPG" /> <img height="200" alt="" width="150" src="/lazysite/user_space/7788/CIMG0059_缩小大小.JPG" /> <img height="150" alt="" width="200" src="/lazysite/user_space/7788/CIMG0063_缩小大小.JPG" /> <img height="150" alt="" width="200" src="/lazysite/user_space/7788/CIMG0070_缩小大小.JPG" /> <img height="150" alt="" width="200" src="/lazysite/user_space/7788/CIMG0071_缩小大小.JPG" /> <img height="150" alt="" width="200" src="/lazysite/user_space/7788/CIMG0072_缩小大小.JPG" /> //这个图片的地址可以是相对的也可以是绝对的 </td><td id=demo2 valign=top></td></tr></table></div><script>var speed=30 demo2.innerHTML=demo1.innerHTML function 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;"> 这段代码中下划线的部分表示我们这段滚动图片所占用区域的大小。用户可根据页面的实际需要进行调节。但一般情况下至少要大于或等于图片的高度和宽度。 <img height="150" alt="" width="200" src="/lazysite/user_space/7788/CIMG0056_缩小大小.JPG" /> 上面这段代码是图片的代码。每加入一行如上代码,那就会多出一个展示的图片。图片可以是一个,也可以是无数个。需要强调的是,每个图片的高度和宽度应尽量的统一大小,主要显示出来的效果才会更好看。 var speed=30 这行代码是控制图片滚动的速度。数字越小,滚动的也就越快;相反,数字越大,滚动的也就越慢。
③ 在淘宝网上如何实现无缝滚动
<table height="161" cellspacing="0" cellpadding="0" width="773" border="0">
<tbody>
<tr>
<td width="773">
<p><marquee style="relative: " scrollamount="1" behavior="alternate" width="740" height="123"><img height="123" width="123" border="0" alt="" src="图片地址1" /><img height="123" width="123" border="0" alt="" src="图片地址2" /><img height="123" width="123" border="0" alt="" src="图片地址3" /><img height="123" width="123" border="0" alt="" src="图片地址4" />
<img height="123" width="123" border="0" alt="" src="图片地址5" /><img height="123" width="123" border="0" alt="" src="图片地址6" />
<img height="123" width="123" border="0" alt="" src="图片地址7" /> <img height="123" width="123" border="0" alt="" src="图片地址8" /><img height="123" width="123" border="0" alt="" src="图片地址9" /></marquee></p>
</td>
</tr>
</tbody>
</table>
④ html图片无缝滚动怎么实现
直接给你一段简单的代码,不懂再问
<html>
<head>
<title>图片滚动 </title>
<style>
#div1
{position:relative;width:650px;height:210px;overflow:hidden;
}
#div2{position:absolute;}
li{float:left;list-style-type:none;padding:5px;}
img{border:none;}
#div2 li a:hover{top:-10px;}
a{position:relative;}
</style>
<script>
window.onload=function()
{
var odiv2=document.getElementById('div2');
var ali=odiv2.getElementsByTagName('li');
var aspeed=-5;
var timer=null;
odiv2.innerHTML+=odiv2.innerHTML;
odiv2.style.width=ali[0].offsetWidth*ali.length+'px';
odiv2.onmouseover=function(){clearInterval(timer);};
function a()
{
timer=setInterval(function()
{
odiv2.style.left=odiv2.offsetLeft+aspeed+'px';
if (odiv2.offsetLeft<-odiv2.offsetWidth/2)
{
odiv2.style.left='0px';
}
},30);};
odiv2.onmouseout=a;
a();
}
</script>
</head>
<body>
<div id='div1'>
<div id='div2'>
<li><a href=""><img src="1.jpg" /></a></li>
<li><a href=""><img src="2.jpg" /></a></li>
<li><a href=""><img src="3.jpg" /></a></li>
<li><a href=""><img src="4.jpg" /></a></li>
</div>
</div>
</body>
</html>
⑤ HTML 无缝文字滚动怎么做
上下无缝滚动代码:
<div id="demo" style="height:50px;overflow:hidden;">
<div id="indemo" style="height:200%;">
<div id="demo1">
第一行字<br />
第二行字
</div>
<div id="demo2"></div>
</div>
</div>
</body>
<script type="text/javascript">
speed = 100; //数字越大滚得越慢
var tab = document.getElementById("demo");
var tab1 = document.getElementById("demo1");
var tab2 = document.getElementById("demo2");
tab2.innerHTML = tab1.innerHTML;
tab.scrollTop = tab1.offsetHeight;
function Marquee(){
if (tab.scrollTop >= tab1.offsetHeight) {
tab.scrollTop-=tab2.offsetHeight;
}else{
tab.scrollTop+=1;
}
}
var MyMar=setInterval(Marquee,speed);
</script>
左右横向无缝滚动代码
<table cellSpacing=0 cellPadding=0 width=100 align=center border=0>
<tr>
<td width=190 bgColor=#d6f6fd height=27></td>
<td bgColor=#d6f6fd height=27>
<marquee onmouseover=this.stop() onmouseout=this.start() scrollAmount=2 scrollDelay=60 width=580 height=20>
<a class="#" href="#" onclick="javascript:window.open('', 'newwindow')" title="\">横向滚动的广告效果 [ 7/13/2012]
<a class="#" href="#" onclick="javascript:window.open('', 'newwindow')" title="\">横向滚动的广告效果2 [ 7/13/2012]
<a class="#" href="#" onclick="javascript:window.open('', 'newwindow')" title="\">横向滚动的广告效果3 [ 7/10/2012]
</marquee>
</td>
</tr>
</table>
⑥ 怎么实现marquee标签的向上无缝滚动
<html>
<head>
<title>TODOsupplyatitle</title>
<metacharset="UTF-8">
<metaname="viewport"content="width=device-width">
</head>
<body>
<style>
#marqueep{height:30px;line-height:30px;margin:0}
</style>
<divstyle="height:30px;overflow:hidden;">
<divid='marquee'>
<p>第1段</p>
<p>第2段</p>
<p>第3段</p>
<p>第4段</p>
<p>第5段</p>
</div>
</div>
<script>
(function(){
varmarquee=document.getElementById('marquee');
varoffset=0;
varscrollheight=marquee.offsetHeight;
varfirstNode=marquee.children[0].cloneNode(true);
marquee.appendChild(firstNode);//还有这里
setInterval(function(){
if(offset==scrollheight){
offset=0;
}
marquee.style.marginTop="-"+offset+"px";
offset+=1;
},50);
})();
</script>
</body></html>
<divid="demo"style="overflow:hidden;height:168px;width:300px;">
<divid="demo1">
<!--此处放要显示的内容-->
</div>
<divid="demo2"></div>
</div>
<scriptlanguage="javascript">
varspeed=30;
vardemo2=document.getElementByIdx_x("demo2");
vardemo1=document.getElementByIdx_x("demo1");
vardemo=document.getElementByIdx_x("demo");
demo2.innerHTML=demo1.innerHTML;
functionMarquee(){
if(demo2.offsetTop-demo.scrollTop<=0){
demo.scrollTop-=demo1.offsetHeight;
}
else{
demo.scrollTop++;
}
}
varMyMar=setInterval(Marquee,speed);
demo.onmouseover=function(){clearInterval(MyMar)};
demo.onmouseout=function(){MyMar=setInterval(Marquee,speed)};
</script>
——【仙】墨纸
⑦ css怎么实现文字无缝上下滚动
155156157158159!DOCTYPEhtmlheadmetahttp-equiv="Content-Type"content="text/html;charset=gb2312"/title向上下左右不间断无缝滚动效果(兼容火狐和IE)/title/headbodydivid="colee"style="overflow:hidden;height:253px;width:410px;"divid="colee1"p此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/p/divdivid="colee2"/div/divscriptvarspeed=30;varcolee2=document.getElementById("colee2");varcolee1=document.getElementById("colee1");varcolee=document.getElementById("colee");colee2.innerHTML=colee1.innerHTML;//克隆colee1为colee2functionMarquee1(){//当滚动至colee1与colee2交界时if(colee2.offsetTop-colee.scrollTop=0){colee.scrollTop-=colee1.offsetHeight;//colee跳到最顶端}else{colee.scrollTop++}}varMyMar1=setInterval(Marquee1,speed)//设置定时器//鼠标移上时清除定时器达到滚动停止的目的colee.onmouseover=function(){clearInterval(MyMar1)}//鼠标移开时重设定时器colee.onmouseout=function(){MyMar1=setInterval(Marquee1,speed)}/script!--向上滚动代码结束--!--下面是向下滚动代码--divid="colee_bottom"style="overflow:hidden;height:253px;width:410px;"divid="colee_bottom1"pimgsrc="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/divdivid="colee_bottom2"/div/divscriptvarspeed=30varcolee_bottom2=document.getElementById("colee_bottom2");varcolee_bottom1=document.getElementById("colee_bottom1");varcolee_bottom=document.getElementById("colee_bottom");colee_bottom2.innerHTML=colee_bottom1.innerHTMLcolee_bottom.scrollTop=colee_bottom.scrollHeightfunctionMarquee2(){if(colee_bottom1.offsetTop-colee_bottom.scrollTop=0)colee_bottom.scrollTop+=colee_bottom2.offsetHeightelse{colee_bottom.scrollTop--}}varMyMar2=setInterval(Marquee2,speed)colee_bottom.onmouseover=function(){clearInterval(MyMar2)}colee_bottom.onmouseout=function(){MyMar2=setInterval(Marquee2,speed)}/script!--向下滚动代码结束--!--下面是向左滚动代码--divid="colee_left"style="overflow:hidden;width:500px;"tablecellpadding="0"cellspacing="0"border="0"trtdid="colee_left1"valign="top"align="center"tablecellpadding="2"cellspacing="0"border="0"tralign="center"tdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/td/tr/table/tdtdid="colee_left2"valign="top"/td/tr/table/divscript//使用div时,请保证colee_left2与colee_left1是在同一行上.varspeed=30//速度数值越大速度越慢varcolee_left2=document.getElementById("colee_left2");varcolee_left1=document.getElementById("colee_left1");varcolee_left=document.getElementById("colee_left");colee_left2.innerHTML=colee_left1.innerHTMLfunctionMarquee3(){if(colee_left2.offsetWidth-colee_left.scrollLeft=0)//offsetWidth是对象的可见宽度colee_left.scrollLeft-=colee_left1.offsetWidth//scrollWidth是对象的实际内容的宽,不包边线宽度else{colee_left.scrollLeft++}}varMyMar3=setInterval(Marquee3,speed)colee_left.onmouseover=function(){clearInterval(MyMar3)}colee_left.onmouseout=function(){MyMar3=setInterval(Marquee3,speed)}/script!--向左滚动代码结束--!--下面是向右滚动代码--divid="colee_right"style="overflow:hidden;width:500px;"tablecellpadding="0"cellspacing="0"border="0"trtdid="colee_right1"valign="top"align="center"tablecellpadding="2"cellspacing="0"border="0"tralign="center"tdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/td/tr/table/tdtdid="colee_right2"valign="top"/td/tr/table/divscriptvarspeed=30//速度数值越大速度越慢varcolee_right2=document.getElementById("colee_right2");varcolee_right1=document.getElementById("colee_right1");varcolee_right=document.getElementById("colee_right");colee_right2.innerHTML=colee_right1.innerHTMLfunctionMarquee4(){if(colee_right.scrollLeft=0)colee_right.scrollLeft+=colee_right2.offsetWidthelse{colee_right.scrollLeft--}}varMyMar4=setInterval(Marquee4,speed)colee_right.onmouseover=function(){clearInterval(MyMar4)}colee_right.onmouseout=function(){MyMar4=setInterval(Marquee4,speed)}/script!--向右滚动代码结束--/body/html常用JS图片、文字滚动(...大小:1.41K 已经过网络安全检测,放心下载点击下载
追问
这是JS的代码?我要的HTML的
⑧ html中怎么实现无缝滚动
给你个例子吧,我这里运行很好,你根据你的需要进行适当的调整应该就可以用的。祝福你!
<div id="demo" style="overflow:hidden;height:141px;width:164px; text-align:left;" onmouseover="clearInterval(MyMar2);" onmouseout="MyMar2=setInterval(Marquee2,speed2);">
<div id="demo1">
<div align="left">滚动内容 <br><br>
</div><br><br>
</div>
<div id="demo2"></div>
</div>
<script>
var speed2=30;
demo2.innerHTML=demo1.innerHTML
function Marquee2()
{
if(demo2.offsetTop-demo.scrollTop<=0)
demo.scrollTop-=demo1.offsetHeight;
else
demo.scrollTop++;
}
var MyMar2=setInterval(Marquee2,speed2);
</script>
</div>
⑨ 3秒滚动一次,且无缝循环滚动,用css3怎么实现
如果你只想使用css3来实现轮播,你就只有通过定位来控制每张图片的位置,使用animate动画来实现轮播