js实现的类marquee水平循环滚动
<script>
var speed=20;/*速度数值越大速度越慢*/
document.getElementById('www_qpsh_com2').innerHTML=document.getElementById('www_qpsh_com1').innerHTML;
/*两个层来回交替出现*/
function Marquee(){
if(document.getElementById('www_qpsh_com2').offsetWidth-document.getElementById('www_qpsh_com').scrollLeft<=0)
document.getElementById('www_qpsh_com').scrollLeft-=document.getElementById('www_qpsh_com1').offsetWidth;
else{
document.getElementById('www_qpsh_com').scrollLeft++;
}
document.getElementById('my_marquee_info').innerHTML='';
document.getElementById('my_marquee_info').innerHTML+='div.scrollTop:'+document.getElementById('www_qpsh_com').scrollLeft;
}
var MyMar=setInterval(Marquee,speed);
www_qpsh_com.onmouseover=function() {clearInterval(MyMar);}
www_qpsh_com.onmouseout=function() {MyMar=setInterval(Marquee,speed);}
</script>
演示代码:
My Marquee Halign
/*My Marquee CSS Start*/
.my_marquee_info{width:200px;border:#987654 solid 1px;padding:20px 3px 3px 2px;margin-top:30px;}
.my_marquee_main{width:200px;height:160px;border:#234567 solid 1px;padding:2px 3px 3px 2px;overflow:hidden;}
.my_marquee_div1{width:195px;border:Green solid 1px;}
.my_marquee_div2{width:195px;border:Red solid 1px;}
/*My Marquee CSS End*/
|
var speed=20;/*速度数值越大速度越慢*/
document.getElementById('www_qpsh_com2').innerHTML=document.getElementById('www_qpsh_com1').innerHTML;
function Marquee(){
if(document.getElementById('www_qpsh_com2').offsetWidth-document.getElementById('www_qpsh_com').scrollLeft
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]