随笔 - 54,  文章 - 1,  评论 - 4,  阅读 - 11万

先展示效果:

  

 

 代码实现:

  

复制代码
<!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{
                width: 80%;
                height:40px;
                margin: 50px auto;
                position: relative;
                text-align: center;
                overflow: hidden;
            }
            .password .password_bg{
                position: absolute;
                left: 0;
                top: 0;
                width: 100%;
                height: 100%;
                overflow: hidden;
            }
            .password .password_bg span{
                float: left;
                margin-right: 3%;
                width: 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;
                width: 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>
复制代码

 

posted on   xzqyun  阅读(160)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示