<html> <head> <title>向左无缝滚动</title> <style type="text/css"> *{ margin:0px; padding: 0px; } #box{ width: 400px; height: 25px; border: 1px solid #ccc; line-height: 25px; white-space:nowrap } span{ font-size: 20px } </style> </head> <body> <div id="box"> <span id="con1"> 吱吱吱吱吱吱吱吱吱吱吱吱吱吱吱吱吱吱吱吱吱吱吱吱 </span> <span id="con2"> </span> </div> <script type="text/javascript"> var box=document.getElementById('box'); var con1=document.getElementById('con1'); var con2=document.getElementById('con2'); con2.innerHTML=con1.innerHTML box.scrollLeft=0; function scrollL(){ if(box.scrollLeft>=con1.offsetWidth){ box.scrollLeft=0; } else{ box.scrollLeft++; } } var mysc=setInterval('scrollL()',30); box.onmouseover=function(){ clearInterval(mysc) } box.onmouseout=function(){ mysc=setInterval('scrollL()',30) } </script> </body> </html>
慕哥1038968
相关分类