① 如何让网页中的图片不间断的滚动
使用MSClass.js组件吧
瞬间解决你水平滚动、垂直滚动,还可以定时滚动,自定义功能强。
www.hanzhen2000.com
你看看他们这个站上的滚动,就是我用MSClass.js解决的。
你可以参考一下。
麻烦采纳,谢谢!
② 在html中滚动图片如何不间断滚动
原生js实现轮播图
很多网站上都有轮播图,但却很难找到一个系统讲解的,因此这里做一个简单的介绍,希望大家都能有所收获,如果有哪些不正确的地方,希望大家可以指出。
github地址 (如果有用,就star一下吧)原理:
将一些图片在一行中平铺,然后计算偏移量再利用定时器实现定时轮播。
③ 图片无间断滚动问题
代码问题不好改
或者换这个无缝上下左右滚动加定高定宽停顿效果 试试吧
④ <marquee>能不能实现图片无间断滚动
在html中使得图片滚动方法很多,其中marquee使用的最多,marquee图片连续不间断滚动,可以向上、向下、向左、向右。通过以下四段不同方向滚动的代码,可以使得图片向不各个方向进行滚动。这里给出向左滚动的具体的事例
在看具体代码之前,了解一下对象的几个的属性:
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="/66php.gif" border="0" /></a>
<a href="#"><img src="66php.gif" border="0" /></a>
<a href="#"><img src="66php.gif" border="0" /></a>
<a href="#"><img src="66php.gif" border="0" /></a>
<a href="#"><img src="66php.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="/66php.gif" border="0" /></a>
<a href="#"><img src="66php.gif" border="0" /></a>
<a href="#"><img src="66php.gif" border="0" /></a>
<a href="#"><img src="66php.gif" border="0" /></a>
<a href="#"><img src="66php.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="/66php.gif" border="0" /></a>
<a href="#"><img src="66php.gif" border="0" /></a>
<a href="#"><img src="66php.gif" border="0" /></a>
<a href="#"><img src="66php.gif" border="0" /></a>
<a href="#"><img src="66php.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="/66php.gif" border="0" /></a>
<a href="#"><img src="66php.gif" border="0" /></a>
<a href="#"><img src="66php.gif" border="0" /></a>
<a href="#"><img src="66php.gif" border="0" /></a>
<a href="#"><img src="66php.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网页设计中,如何设置无间断循滚动环图片
这是我曾经写的一个简易二次方缓动轮播器/**
* Player 轮播器
* @param object obj
* @author [email protected]
* obj{
* frame //内容框架,position:absolute;
* lists //轮播内容节点数组,注意这个父容器的lists复写一次,如果是ul,则ul.innerHTML+=ul.innerHTML,呈现不间断滚动
* time //跳帧时间3000ms
*
* }
*/
function Player(obj){
this.frame=obj.frame, //内容框架
this.lists=obj.lists, //移动节点
this.time=obj.time||3000, //帧翻滚间隔
this.index=0, //初始化第一帧位置
this.step=this.lists[0].offsetHeight||0 ; //翻滚步长
this.run();
}
Player.prototype={
//跳帧
skip:function(time){
this.skipInterval&&clearInterval(this.skipInterval);
var _this=this;
var des=this.lists[this.index].relatedPosition;
var t=0;
this.skipInterval=setInterval(function(){
t+=10;
_this.frame.style.top=_this.lists[_this.index-1].relatedPosition-Math.ceil(_this.step*Math.pow(t/time,2))+"px";
if(t==time){
clearInterval(_this.skipInterval);
}
},10);
},
//下一帧
next:function(){
this.index+=1;
if(this.index>this.lists.length/2) {
this.frame.style.top="0px";
this.index=1;
}
this.skip(300);
},
//开始跳帧
start:function(){
var _this=this;
this.interval=setInterval(function(){
_this.next();
},this.time);
},
//停止跳帧
stop:function(){
clearInterval(this.interval);
},
//初始化轮播器
run:function(){
this.start();
this.deal();
},
//帧处理
deal:function(){
var _this=this;
for(var i=0;i<this.lists.length;i++){
this.lists[i].relatedPosition=-this.lists[i].offsetTop;
this.lists[i].onmouseover=function(){
_this.stop();
}
this.lists[i].onmouseout=function(){
_this.start();
}
}
}
}
⑥ 图片不间断左右滚动效果,并且可以控制方向
<div id="demo" style="overflow:hidden;width:510px; border:1px solid blue;">
<div id="demo1">
<table cellspacing="0">
<tr>
<td><img src="http://www..com/img/lm.gif"></td>
<td><img src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/logo-.gif"></td>
<td><img src="http://www..com/img/lm.gif"></td>
<td><img src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/logo-.gif"></td>
<td><img src="http://www..com/img/lm.gif"></td>
<td><img src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/logo-.gif"></td>
<td><img src="http://www..com/img/lm.gif"></td>
<td><img src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/logo-.gif"></td>
<td><img src="http://www..com/img/lm.gif"></td>
<td><img src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/logo-.gif"></td>
<td><img src="http://www..com/img/lm.gif"></td>
<td><img src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/logo-.gif"></td>
<td><img src="http://www..com/img/lm.gif"></td>
<td><img src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/logo-.gif"></td>
<td><img src="http://www..com/img/lm.gif"></td>
<td><img src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/logo-.gif"></td>
</tr>
</table>
</div>
<div id="demo2"></div>
</div>
<input type="button" value="向左" onclick="changeRedirect(0)">
<input type="button" value="向右" onclick="changeRedirect(1)">
<script style="text/javascript">
var speed=40;//数值越大,速度越慢
var demo2=document.getElementById("demo2");
var demo1=document.getElementById("demo1");
var demo=document.getElementById("demo");
demo.scrollLeft=demo.scrollWidth
function MarqueeLeft(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
function MarqueeRight(){
if(demo.scrollLeft<=0)
demo.scrollLeft+=demo2.offsetWidth
else{
demo.scrollLeft--
}
}
var MyMar=setInterval(MarqueeRight,speed);
demo.onmouseover=function() {clearInterval(MyMar);}
demo.onmouseout=function() {MyMar=setInterval(MarqueeRight,speed);}
function changeRedirect(i)
{
clearInterval(MyMar);
if(i==0)
{
MyMar=setInterval(MarqueeLeft,speed);
demo.onmouseout=function() {MyMar=setInterval(MarqueeLeft,speed);}
}
else
{
MyMar=setInterval(MarqueeRight,speed);
demo.onmouseout=function() {MyMar=setInterval(MarqueeRight,speed);}
}
}
</script>
⑦ 如何在HTML实现图片无间隙循环滚动
<SCRIPT language=JavaScript>
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;
// Specify the image files
var Pic = new Array();
// to add more images, just continue
// the pattern, adding to the array below
Pic[0] = 'images2005/03/1.gif' 图片路径
Pic[1] = 'images2005/03/2.gif'
Pic[2] = 'images2005/03/3.gif'
Pic[3] = 'images2005/03/4.gif'
Pic[4] = 'images2005/03/5.gif'
Pic[5] = 'images2005/03/6.gif'
Pic[6] = 'images2005/03/7.gif'
Pic[7] = 'images2005/03/8.gif'
Pic[8] = 'images2005/03/9.gif'
Pic[9] = 'images2005/03/10.gif'
// do not edit anything below this line
var t;
var j = 0;
var p = Pic.length;
var preLoad = new Array();
for (i = 0; i < p; i++) {
preLoad = new Image();
preLoad.src = Pic;
}
function runSlideShow() {
if (document.all) {
document.images.SlideShow.style.filter="blendTrans(ration=2)";
document.images.SlideShow.style.filter="blendTrans(ration=crossFadeDuration)";
document.images.SlideShow.filters.blendTrans.Apply();
}
document.images.SlideShow.src = preLoad[j].src;
if (document.all) {
document.images.SlideShow.filters.blendTrans.Play();
}
j = j + 1;
if (j > (p - 1)) j = 0;
t = setTimeout('runSlideShow()', slideShowSpeed);
}
</SCRIPT>
将BODY改为 <BODY onload=runSlideShow()>
⑧ 网站图片连续不间断滚动
参数自己可以修改一下
<div class="zhanshi" id="demo" style="overflow:hidden;height:auto;width:663px;color:#ff0000;">
<table align=left cellpadding=0 cellspace=0 border=0>
<tr>
<td id="demo1" valign="top">
<table>
<tr>
<td><img src="dsfdf" width="200"/></td>
<td><img src="dsfdf" width="200"/></td>
<td><img src="dsfdf" width="200"/></td>
<td><img src="dsfdf" width="200"/></td>
</tr>
</table>
</td>
<td id="demo2" valign="top"></td>
</tr>
</table>
</div>
<script>
var demo=document.getElementById("demo")
var demo1=document.getElementById("demo1")
var demo2=document.getElementById("demo2")
var speed=1//速度数值越大速度越慢
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo1.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
window.onload=function(){
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
}
</script>