zoukankan      html  css  js  c++  java
  • 输入掩码密码

    先展示效果:

      

     代码实现:

      

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
            <title></title>
             <style type="text/css" >
                *{margin: 0;padding: 0;border: 0;outline: 0;font-size: 100%;vertical-align: baseline;background: transparent;}   
                *{tap-highlight-color:rgba(0,0,0,0); -webkit-tap-highlight-color:rgba(0,0,0,0);}
                
                .password{
                     80%;
                    height:40px;
                    margin: 50px auto;
                    position: relative;
                    text-align: center;
                    overflow: hidden;
                }
                .password .password_bg{
                    position: absolute;
                    left: 0;
                    top: 0;
                     100%;
                    height: 100%;
                    overflow: hidden;
                }
                .password .password_bg span{
                    float: left;
                    margin-right: 3%;
                     14%;
                    height: 100%;
                    line-height: 40px;
                    height: 40px;
                    font-size: 100px;
                    background-color: #f1f1f1;
                }
                .password .password_bg span:last-child{margin: 0;}
                
                .password input{
                    position: absolute;
                    left: -100%;
                    top: 0;
                    -webkit-appearance: none;
                    appearance: none;
                     200%;
                    height: 100%;
                    opacity: 0;
                }
                p{text-align: center;}
             </style>
        </head>
        <body>
    
            <div class="password">
                <div class="password_bg" id="showPasswd">
                    <span></span>
                    <span></span>
                    <span></span>
                    <span></span>
                    <span></span>
                    <span></span>
                </div>
                <input type="tel" id="passwd" maxlength="6">
            </div>
    
    
           <p>提交</p>
    
        </body>
    </html>
    
    <script>
    
    var aSpan = QueryAll("#showPasswd span");
    Query("#passwd").addEventListener("input",function(){
       var len = this.value.length;
      for (var i = 0; i< aSpan.length; i++){
             if(len > 0){
                  aSpan[i].innerHTML = "·";
                  len--;
              }else{
                  aSpan[i].innerHTML = "";;
              }
      };
    },false);
    
    
    
    Query("p").onclick = function (){
        alert(Query("#passwd").value ) ;
    }
    
    function Query(e){return document.querySelector(e);}
    function QueryAll(e){return document.querySelectorAll(e);}
    
    </script>
  • 相关阅读:
    漏斗算法 java
    servlet request参数只能取一次解决方法
    redis的使用
    关于Http协议与TCP协议的一些简单理解
    OSI七层与TCP/IP五层网络架构详解
    linux命令详解——eval
    使用apache benchmark(ab) 测试报错: apr_socket_recv: Connection timed out (110)
    hadoop相关随记
    mesos-master启动失败,报错Failed to load unknown flag 'quorum.rpmsave'
    根目录/缺少执行权限x产生的两种错误
  • 原文地址:https://www.cnblogs.com/xzqyun/p/15697630.html
Copyright © 2011-2022 走看看