石家庄网站制作联系电话:13292823610 郭先生 QQ咨询:您当前的位置:首页 > 网站制作

js文字不间断向上滚动代码

    来源:石家庄网站建设  发表时间: 2011年02月25日    作者:石家庄轻程网络  浏览次数:

<style type="text/css">
  h1 {
    font:400 16px/1 "Microsoft YaHei",KaiTi_GB2312,SimSun
  }
  #marquee,#marquee li {
    margin:0;
    padding:0;
    list-style:none;
  }
  #marquee {
    position:relative;
    height:100px;
    width:280px;
    overflow:hidden;
    border:10px solid #c0c0c0;
  }
  #marquee a {
    display:block;
    padding:5px;
    text-decoration:none;
    white-space: nowrap;
    color:#000;
  }
  #marquee a:hover{
    background: #efefda;
    color:#3bcdfe
  }
</style>
<script type="text/javascript">
  var Marquee = function(id){
    try{document.execCommand("BackgroundImageCache", false, true);}catch(e){};
    var container = document.getElementById(id),
    original = container.getElementsByTagName("li")[0],
    speed = arguments[1] || 10,
    clone = original.cloneNode(true);
    container.appendChild(clone);
    var rolling = function(){
      if(container.scrollTop == clone.offsetTop){
        container.scrollTop = 0;
      }else{
        container.scrollTop++;
      }
    }
    var timer = setInterval(rolling,speed)//设置定时器
    container.onmouseover=function() {clearInterval(timer)}//鼠标移到marquee上时,清除定时器,停止滚动
    container.onmouseout=function() {timer=setInterval(rolling,speed)}//鼠标移开时重设定时器
  }
  window.onload = function(){
    Marquee("marquee");
  }
</script>

<ul id="marquee">
  <li>
    <a href="08/08/1541914.html">一步步教你实现纯CSS的柱形图</a>
    <a href="09/02/1558998.html">javascript十个最常用的自定义函数</a>
    <a href="08/24/1552862.html">javascript鼠标事件总结</a>
    <a href="09/14/1566157.html">一个很简单的淡入淡出相册</a>
    <a href="09/18/1568925.html">纯CSS相册</a>
    <a href="08/13/1544365.html">一步步教你实现表格排序(第一部分)</a>
  </li>
</ul>

相关内容