网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的范文:

 

标题 javascript 广告移动特效的实现代码
范文
    下面小编就为大家带来一篇javascript 广告移动特效的实现代码。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>Document</title>
      <style>
        .box2{}
        .box2{width: 200px; height: 200px; background: red; border-radius: 50%;position: relative;}
        .box3{width: 800px; height: 500px; border:1px solid red;}
      </style>
    </head>
    <body>
    <button type="" id="start">开始</button>
    <button type="" id="stop">停止</button>
    <div>
      <div id="box">
      </div>
      </div>
    </body>
    <script type="text/javascript">
      var lr=600;
      var tb=300;
      var i=0;
      var j=0;
      var box=document.getElementById('box');
      var start=document.getElementById('start');
      var stop=document.getElementById('stop');
      start.onclick=function(){
        start.style.display='none';
        stop.style.display='inline';
        var time=setInterval(function(){
          box.style.left=i+'px';
          box.style.top=j+'px';
          if (i>lr) {
            lr=0;
            i--;
          }
          if(i<=lr){
            lr=600;
            i++;
          }
          if (j>tb) {
            tb=0;
            j--;
          }
          if (j<=tb) {
            tb=300;
            j++
          }
          stop.onclick=function(){
            clearInterval(time);
            stop.style.display='none';
            start.style.display='inline';
          }
        },5);
      }
    </script>
    </html>
    以上就是小编为大家带来的javascript 广告移动特效的实现代码全部内容了
随便看

 

在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/13 4:53:36