您的位置:首页 > Web前端 > JavaScript

js文字内容左右移动事件

2016-12-13 11:39 267 查看
<style type="text/css">

#gongao{width:500px;height:30px;overflow:hidden;line-height:30px;font-size:13px;font-family:'宋体';

background:#DDE5ED;color:#0C77CF;font-weight:bold; position: absolute;right: 20px;top: 100px;}

#gongao #scroll_begin, #gongao #scroll_end{display:inline}

</style>

<!-- js字体左右移动-->

<script type="text/javascript">

function ScrollImgLeft(){

var speed=50;  //设置调用时间

var scroll_div = document.getElementById("scroll_div");  //获取left需要移动的idv

function Marquee(){

if(scroll_div.scrollLeft>300)    

scroll_div.scrollLeft=0;

else

scroll_div.scrollLeft++;

}

var MyMar=setInterval(Marquee,speed);  //每多少秒调用一次该函数

scroll_div.onmouseover=function() {clearInterval(MyMar);}  //鼠标移动停止移动事件

scroll_div.onmouseout=function() {MyMar=setInterval(Marquee,speed);}  //离开运行移动

}

</script>

<div id="gongao">

<div style="width:500px;height:30px;margin:0 auto;white-space: nowrap;overflow:hidden;" id="scroll_div" class="scroll_div">

<div id="scroll_begin">

由于电信对座机号码设置的管控,公司现正式更换热线号码为:028-63433266       

由于电信对座机号码设置的管控,公司现正
ace6
式更换热线号码为:028-63433266       

由于电信对座机号码设置的管控,公司现正式更换热线号码为:028-63433266     

</div>

</div>

<script type="text/javascript">setInterval(ScrollImgLeft(),1000);</script>

</div>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: