欢迎来到奇迪科技(深圳)有限公司,超值服务提供卓越产品!
JS控制横向滚动文字、滚动字幕
JS代码
<script type="text/javascript"> function ScrollImgLeft(){ var speed=50; var MyMar = null; var scroll_begin = document.getElementById("scroll_begin"); var scroll_end = document.getElementById("scroll_end"); var scroll_div = document.getElementById("scroll_div"); scroll_end.innerHTML=scroll_begin.innerHTML; function Marquee(){ if(scroll_end.offsetWidth-scroll_div.scrollLeft<=0) scroll_div.scrollLeft-=scroll_begin.offsetWidth; else scroll_div.scrollLeft++; } MyMar=setInterval(Marquee,speed); scroll_div.onmouseover = function(){ clearInterval(MyMar); } scroll_div.onmouseout = function(){ MyMar = setInterval(Marquee,speed); } } ScrollImgLeft(); </script>
HTML
<div id="scroll_div" class="fl"> <div id="scroll_begin"> 《王者荣耀》是由腾讯游戏开发并运行的一款运营在Android、IOS平台上的MOBA类手机游戏。 </div> <div id="scroll_end"></div> </div>
CSS:
/*滚动字幕*/ #scroll_div {height:20px;overflow: hidden;white-space: nowrap;margin:0 auto;width:80%;} #scroll_begin,#scroll_end {display: inline;}
本文版权所有,转载须注明:来源 https://www.qvdv.net/qvdv-oop-866.html