常见的js滚动(无缝,平滑,上下滚动)代码书(推荐)

常见的js滚动(无缝,平滑,上下滚动)代码书(推荐)
废话没多说,直接给大家粘上代码,具体代码如下所示:



var速度= 30;
无功colee2 = document.getelementbyid(colee2 );
无功colee1 = document.getelementbyid(colee1 );
VaR Colee = document.getelementbyid(Colee );
对colee1 colee2 colee2克隆.innerHTML = colee1.innerhtml; / /
功能marquee1(){
当滚动到colee1 / / colee2结
如果(colee2。offsettop Colee。scrollTop <= 0){
Colee。scrollTop = colee1.offsetheight; / / Colee跳跃到顶端
其他{ }
Colee。scrollTop + +
}
}
无功mymar1 = setInterval(marquee1,速度) / /设置定时器
/ /当鼠标移动到停止滚动达到清除定时器
Colee。onmouseover =函数(){ clearInterval(mymar1)}
/ / onmouseout复位定时器
Colee。onmouseout=函数(){ mymar1 = setInterval(marquee1,速度)}


var速度= 30
无功colee_bottom2 = document.getelementbyid(colee_bottom2 );
无功colee_bottom1 = document.getelementbyid(colee_bottom1 );
无功colee_bottom = document.getelementbyid(colee_bottom );
colee_bottom2 .innerHTML = colee_bottom1.innerhtml
colee_bottom scrollTop = colee_bottom.scrollheight。
功能marquee2(){
如果(colee_bottom1。offsettop-colee_bottom。scrollTop > = 0)
colee_bottom scrollTop + = colee_bottom2.offsetheight。
别的{
colee_bottom.scrolltop-—
}
}
无功mymar2 = setInterval(marquee2,速度)
colee_bottom。onmouseover =函数(){ clearInterval(mymar2)}
colee_bottom。onmouseout=函数(){ mymar2 = setInterval(marquee2,速度)}


DIV / /使用,请确保colee_left2和colee_left1是在同一行。
var速度越高,速度越快,速度越慢,速度越慢,速度越快,速度越快,速度越快,速度越快,速度越快,速度越快,速度越快,速度越快,速度越快,速度越快。
无功colee_left2 = document.getelementbyid(colee_left2 );
无功colee_left1 = document.getelementbyid(colee_left1 );
无功colee_left = document.getelementbyid(colee_left );
colee_left2 .innerHTML = colee_left1.innerhtml
功能marquee3(){
如果(colee_left2。offsetwidth-colee_left。scrollLeft <= 0) / / offsetwidth是对象的可见宽度
colee_left。scrollLeft = colee_left1。offsetwidth / / scrollwidth是对象的实际内容的宽度,没有线的宽度
别的{
colee_left scrollLeft + +。
}
}
无功mymar3 = setInterval(marquee3,速度)
colee_left。onmouseover =函数(){ clearInterval(mymar3)}
colee_left。onmouseout=函数(){ mymar3 = setInterval(marquee3,速度)}



var速度越高,速度越快,速度越慢,速度越慢,速度越快,速度越快,速度越快,速度越快,速度越快,速度越快,速度越快,速度越快,速度越快,速度越快。
无功colee_right2 = document.getelementbyid(colee_right2 );
无功colee_right1 = document.getelementbyid(colee_right1 );
无功colee_right = document.getelementbyid(colee_right );
colee_right2 .innerHTML = colee_right1.innerhtml
功能marquee4(){
如果(colee_right。scrollLeft < = 0)
colee_right scrollLeft + = colee_right2.offsetwidth。
别的{
colee_right.scrollleft-—
}
}
无功mymar4 = setInterval(marquee4,速度)
colee_right。onmouseover =函数(){ clearInterval(mymar4)}
colee_right。onmouseout=函数(){ mymar4 = setInterval(marquee4,速度)}

以上是一系列常用的JS图片滚动(无缝、平滑,向上或向下),这是由萧边介绍。我们希望能帮助你。如果你有任何问题,请给我留言,萧边会及时给您回复。谢谢您支持网站
免责声明:本网信息来自于互联网,目的在于传递更多信息,并不代表本网赞同其观点。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,并请自行核实相关内容。本站不承担此类作品侵权行为的直接责任及连带责任。如若本网有任何内容侵犯您的权益,请及时联系我们,本站将会在24小时内处理完毕。
相关文章
返回顶部