欢迎来到代码驿站!

JavaScript代码

当前位置:首页 > 网页前端 > JavaScript代码

向左滚动文字 js代码效果

时间:2021-01-29 09:31:38|栏目:JavaScript代码|点击:

复制代码 代码如下:

<html>
<head>
<title>滚动文字效果</title>
<style type="text/css">
#infozone{font-size:12px;color:#aa6;overflow:hidden;width:100px;height:20px;}
#infozone div{height:20px;line-height:20px;white-space:nowrap;overflow:hidden;}
</style>
<script type="text/javascript">
var tc;
window.onload=function(){
 var o=document.getElementById('infozone');hscroll(o);
 window.setInterval(function(){window.clearTimeout(tc);o.firstChild.style.marginLeft='0px';scrollup(o,20,0);},10000);
}
function scrollup(o,d,c){
 if(d==c){
  var t=o.firstChild.cloneNode(true);
  o.removeChild(o.firstChild);o.appendChild(t);
  t.style.marginTop=o.firstChild.style.marginTop='0px';
  hscroll(o);
 }
 else{
  ch=false;var s=3,c=c+s,l=(c>=d?c-d:0);
  o.firstChild.style.marginTop=-c+l+'px';
  window.setTimeout(function(){scrollup(o,d,c-l)},50);
 }
}

function hscroll(o){
 var w1=o.firstChild.offsetWidth,w2=o.offsetWidth;
 if(w1<=w2)return;
 tc=window.setTimeout(function(){hs(o,w1-w2,0,w1-w2)},3500);
}

function hs(o,d,c,p){
 c++;var t=(c>0?-c:c);o.firstChild.style.marginLeft=t+'px';
 if(c==d){if(d==0){tc=window.setTimeout(function(){hs(o,p,0,p)},2500);}else tc=window.setTimeout(function(){hs(o,0,-p,p)},3500);}
 else tc=window.setTimeout(function(){hs(o,d,c,p)},5);
}
</script>
</head>

<body>
<div id="infozone"><div>C# 鼠标属性动态操作相关源码示例,比如、隐藏与显示鼠标指针、将鼠标左右键功能互换、更换鼠标指针形状、调用Windows鼠标设置面板等,小技巧,多多益善。</div></div>
</body>
</html></td>
   </tr>
 </table>

上一篇:javascript时间排序算法实现活动秒杀倒计时效果

栏    目:JavaScript代码

下一篇:react-router4 嵌套路由的使用方法

本文标题:向左滚动文字 js代码效果

本文地址:http://www.codeinn.net/misctech/53253.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有