zoukankan      html  css  js  c++  java
  • 交通红绿灯

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style type="text/css">
    
        ul{
            list-style: none;
        }
       #traffic>li{
            display:block;
        }
        #traffic span{
              display:inline-block;
              50px;
             height:50px;
              background-color:gray;
              margin:5px;
             border-radius:50%;
             float:left;
        }
         #traffic.stop li:nth-child(1) span{
             background-color:yellow;
         }
         #traffic.wait li:nth-child(2) span{
             background-color:red;
         }
         #traffic.pass li:nth-child(3) span{
             background-color:green;
         }
    
        </style>
    </head>
    <body>
    <ul id="traffic">
        <li><span></span></li>
        <li><span></span></li>
        <li><span></span></li>
    </ul>
    
    <script>
    
    /*const traffic = document.getElementById("traffic");
      (function reset(){
          traffic.className = "wait";
      
          setTimeout(function(){
              traffic.className = "stop";
              setTimeout(function(){
                  traffic.className = "pass";
                  setTimeout(reset,2000);
             },2000);
         },2000);
     })();*/
    
    
    const traffic = document.getElementById("traffic");
    var stateList = ["wait", "stop", "pass"];
    var currentStateIndex = 0;
    setInterval(function(){
    var state = stateList[currentStateIndex];
    traffic.className = state;
    currentStateIndex = (currentStateIndex + 1) % stateList.length;
    },2000);
    
    </script>
    </body>
    </html>
  • 相关阅读:
    Gson字符串编码,字符串转换成图片保存,二进制转换成图片保存
    时间工具类DateUtil
    RSA 签名、验证、加密、解密帮助类
    富友数据加密解密
    Base64(2)
    MD5(2)
    实体对象操作工具
    HttpClient工具类
    MD5
    身份证算法实现
  • 原文地址:https://www.cnblogs.com/dexin/p/6375033.html
Copyright © 2011-2022 走看看