• 图片切换 电视机屏保效果


    编程的核心是思路。

    1 <div id="box">
    2     <div id="wrap">
    3     </div>
    4 </div>
     1 <style>
     2     body{
     3         margin: 0;
     4         background-color: #5e5e5e;
     5     }
     6     #box{
     7         width: 857px;
     8         height: 574px;
     9         padding-top: 126px;
    10         padding-left:143px;
    11         background: url(img/bg.png) no-repeat;
    12         margin: 0px auto;
    13     }
    14     #wrap{
    15         width: 700px;
    16         height: 420px;
    17         transform-style: preserve-3d;
    18         perspective: 800px;
    19     }
    20     #wrap div{
    21         width: 10px;
    22         height: 420px;
    23         background: url(img/01.png) no-repeat;
    24         float: left;
    25         transition: .5s;
    26     }
    27 </style>
    <script type="text/javascript">
       window.onload = function(){
            var  wrap = document.getElementById("wrap");
          var str = ""
           for (var i = 0; i <70; i++) {
               str += "<div style ='background-Position-X :"+(-10*i)+"px'+></div>"
           }
           wrap.innerHTML = str;
           var divs = wrap.getElementsByTagName("div");
           var num = 0;
           var timer ;
           var imgnum = 2; //从第二张开始变
           go();
           function go()
           {
                timer = setInterval(function(){
                     tab(num);
                     num++;
                            if(num == 71){   //为什么是71   因为  第 divs[n -1] = divs [69]  n = 70
                         clearInterval(timer);//不清定时器的后果是  动画速度累加  一次结束加一次
                         console.log("一次结束了")
                         imgnum++;
                         if(imgnum == 6){
                             imgnum = 1;
                         }
                         num = 0;
                         setTimeout(go,500);
                     }
                },80)
          
           }
        
           function tab ( n)  //切换的效果是  前一张变不透明   当前一张透明
           {
               if (divs[n-1]) {
               divs[n-1].style.opacity = 1; 
           
               }
               if(divs[n]) 
               {
                   divs[n].style.opacity = 0;
                   divs[n].style.backgroundImage = "url(img/0"+imgnum+".png)";
               }
           }
       }
         
    </script>
  • 相关阅读:
    运算符重载
    简单函数template max
    const static extern
    python 关闭垃圾回收
    Easy and cheap cluster building on AWS backup
    [转] Maven更新父子模块的版本号, mvn versions:set
    [转] ansible批量执行命令展示
    HBase 批量删除表 disable_all drop_all
    自动添加 ssh key 到远程主机的脚本,应用sshpass和ssh-copy-id
    MongoDB ver 4 几个常用命令
  • 原文地址:https://www.cnblogs.com/h5monkey/p/5918834.html
Copyright © 2020-2023  润新知