先奉上效果图
html代码
<!DOCTYPE html> <html> <head> <title>仿手机微信支付输入密码界面效果</title> <meta charset="utf-8" /> <meta name="viewport" content="initial-scale=1.0, width=device-width, user-scalable=no" /> <link rel="stylesheet" type="text/css" href="css/rest.css" rel="external nofollow" /> </head> <body> <!-- 打开弹窗按钮 --> <button id="myBtn">去支付</button> <!-- 弹窗 --> <div id="myModal" class="modal"> <!-- 弹窗内容 --> <div class="modal-content"> <div class="paymentArea"> <div class="paymentArea-Entry"> <div class="paymentArea-Entry-Head"> <img src="/UploadFiles/2021-04-02/xx_03.jpg">css
body { margin: 0; padding: 0; font-size: 0.3rem; font-family: "微软雅黑", arial; } ul, li { margin: 0; padding: 0; list-style: none; } img { display: block; } #myBtn { display: block; width: 80%; height: auto; margin: 5rem auto; padding: 0.2rem; border-radius: 5px; border: 0; outline: none; font-family: "微软雅黑"; color: #fff; background-color: #5CB85C; } /* 弹窗 */ .modal { display: none; /* 默认隐藏 */ position: fixed; z-index: 1; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0.4); -webkit-animation-name: fadeIn; -webkit-animation-duration: 0.4s; animation-name: fadeIn; animation-duration: 0.4s } /* 弹窗内容 */ .modal-content { position: fixed; bottom: 0; /*background-color: #fefefe;*/ width: 100%; -webkit-animation-name: slideIn; -webkit-animation-duration: 0.4s; animation-name: slideIn; animation-duration: 0.4s } /** * 支付弹窗样式 * **/ .paymentArea-Entry { width: 90%; margin: 0 auto; padding-bottom: 0.3rem; background-color: #fff; } .paymentArea-Entry-Head { display: flex; display: -webkit-flex; height: 0.8rem; line-height: 0.8rem; padding: 0.2rem; border-bottom: 1px solid #5CB85C; } /* 关闭按钮 */ .paymentArea-Entry-Head .close { width: 0.5rem; height: 0.5rem; padding: 0.15rem 0.15rem 0.15rem 0; } .paymentArea-Entry-Head .close:hover, .paymentArea-Entry-Head .close:focus { color: #000; text-decoration: none; cursor: pointer; } .paymentArea-Entry-Head .useImg { width: 0.8rem; height: 0.8rem; margin-right: 0.15rem; } .paymentArea-Entry-Head .tips-txt { font-size: 0.4rem; } .paymentArea-Entry-Content { position: relative; padding: 0.2rem 0; text-align: center; } .paymentArea-Entry-Content:after { content: ""; position: absolute; bottom: 0; left: 0.3rem; right: 0.3rem; height: 1px; background-color: #ddd; } .paymentArea-Entry-Content .pay-name { font-size: 0.3rem; } .paymentArea-Entry-Content .pay-price { font-size: 0.4rem; font-weight: bold; } ul.paymentArea-Entry-Row { display: flex; display: -webkit-flex; justify-content: space-between; margin: 0.2rem 0.3rem 0 0.3rem; padding: 0; border: 1px solid #a2a2a2; } ul.paymentArea-Entry-Row li { position: relative; flex-grow: 1; min-width: 1rem; height: 0.8rem; line-height: 0.8rem; text-align: center; border-right: 1px solid #ddd; } ul.paymentArea-Entry-Row li:last-child { border-right: 0; } ul.paymentArea-Entry-Row li img { position: absolute; top: 50%; left: 50%; width: 0.5rem; height: 0.5rem; margin: -0.25rem 0 0 -0.25rem; } .paymentArea-Keyboard { margin-top: 1.2rem; background-color: #fff; } .paymentArea-Keyboard h4 { height: 0.5rem; line-height: 0.5rem; margin: 0; text-align: center; } .paymentArea-Keyboard h4 img { width: 0.93rem; height: 0.32rem; margin: 0 auto; } .paymentArea-Keyboard h4:active { background-color: #e3e3e3; } .paymentArea-Keyboard ul { border-top: 1px solid #ddd; } .paymentArea-Keyboard li { display: flex; display: -webkit-flex; justify-content: space-between; border-bottom: 1px solid #ddd; } .paymentArea-Keyboard li a { flex-grow: 1; display: block; min-width: 1rem; line-height: 1rem; border-right: 1px solid #ddd; font-size: 0.3rem; text-align: center; text-decoration: none; color: #000; } .paymentArea-Keyboard li:last-child, .paymentArea-Keyboard li a:last-child { border: 0; } .paymentArea-Keyboard li a:active { outline: none; background-color: #ddd; } /* 添加动画 */ @-webkit-keyframes slideIn { from { bottom: -300px; opacity: 0 } to { bottom: 0; opacity: 1 } } @keyframes slideIn { from { bottom: -300px; opacity: 0 } to { bottom: 0; opacity: 1 } } @-webkit-keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } } @keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }js
//定义根目录字体大小,通过rem实现适配 document.addEventListener("DOMContentLoaded", function() { var html = document.documentElement; var windowWidth = html.clientWidth; //console.log(windowWidth) html.style.fontSize = windowWidth / 7.5 + "px"; }, false); // 获取弹窗 var modal = document.getElementById('myModal'); // 打开弹窗的按钮对象 var btn = document.getElementById("myBtn"); // 获取 <span> 元素,用于关闭弹窗 that closes the modal var span = document.getElementsByClassName("close")[0]; /*创建密码输入框*/ var entryArea = document.querySelector(".paymentArea-Entry-Row"); for(var i = 0; i < 6; i++) { var li = document.createElement("li"); entryArea.appendChild(li); } /*键盘操作*/ var doms = document.querySelectorAll('ul li a'); var entryLis = document.querySelectorAll(".paymentArea-Entry-Row li"); var pwds = ""; //存储密码 var count = 0; //记录点击次数 for(var i = 0; i < doms.length; i++) { ! function(dom, index) { dom.addEventListener('click', function() { var txt = this.innerHTML; switch(txt) { case "清空": if(count != 0) { for(var i = 0; i < entryLis.length; i++) { entryLis[i].innerHTML = ""; } pwds = ""; count = 0; console.log(pwds) console.log(count) } break; case "删除": if(count != 0) { console.log(pwds) entryLis[count - 1].innerHTML = ""; pwds = pwds.substring(0, pwds.length - 1); count--; console.log(pwds) console.log(count) } break; default: /*通过判断点击次数 向输入框填充内容*/ if(count < 6) { /*创建一个图片对象 插入到方框中*/ var img = new Image(); img.src = "images/dd_03.jpg"; entryLis[count].appendChild(img); /*为存储密码的对象赋值*/ if(pwds == "") { pwds = txt; } else { pwds += txt; } count++; if(pwds.length == 6) { location.href = "https://www.baidu.com"; } } else { return; alert("超出限制") } } }); }(doms[i], i); } // 点击按钮打开弹窗 btn.onclick = function() { modal.style.display = "block"; } // 点击 <span> (x), 关闭弹窗 span.onclick = function() { modal.style.display = "none"; if(count != 0) { for(var i = 0; i < entryLis.length; i++) { entryLis[i].innerHTML = ""; } pwds = ""; count = 0; } } // 在用户点击其他地方时,关闭弹窗 window.onclick = function(event) { if(event.target == modal) { modal.style.display = "none"; if(count != 0) { for(var i = 0; i < entryLis.length; i++) { entryLis[i].innerHTML = ""; } pwds = ""; count = 0; } } } /*开关键盘*/ var openKey = document.querySelector(".paymentArea-Entry-Row"); var switchOfKey = document.querySelector(".paymentArea-Keyboard h4"); switchOfKey.addEventListener('click', function() { var KeyboardH = document.querySelector(".paymentArea-Keyboard").clientHeight; document.querySelector(".paymentArea-Keyboard").style.height = KeyboardH + "px"; document.querySelector(".paymentArea-Keyboard").style.backgroundColor = "transparent"; document.querySelector(".paymentArea-Keyboard h4").style.display = "none"; document.querySelector(".paymentArea-Keyboard ul").style.display = "none"; }) openKey.addEventListener('click', function() { document.querySelector(".paymentArea-Keyboard").style.backgroundColor = "#fff"; document.querySelector(".paymentArea-Keyboard h4").style.display = "block"; document.querySelector(".paymentArea-Keyboard ul").style.display = "block"; })总结
以上所述是小编给大家介绍的JS实现仿微信支付弹窗功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。
更新日志
2024年11月17日
2024年11月17日
- 【雨果唱片】中国管弦乐《鹿回头》WAV
- APM亚流新世代《一起冒险》[FLAC/分轨][106.77MB]
- 崔健《飞狗》律冻文化[WAV+CUE][1.1G]
- 罗志祥《舞状元 (Explicit)》[320K/MP3][66.77MB]
- 尤雅.1997-幽雅精粹2CD【南方】【WAV+CUE】
- 张惠妹.2007-STAR(引进版)【EMI百代】【WAV+CUE】
- 群星.2008-LOVE情歌集VOL.8【正东】【WAV+CUE】
- 罗志祥《舞状元 (Explicit)》[FLAC/分轨][360.76MB]
- Tank《我不伟大,至少我能改变我。》[320K/MP3][160.41MB]
- Tank《我不伟大,至少我能改变我。》[FLAC/分轨][236.89MB]
- CD圣经推荐-夏韶声《谙2》SACD-ISO
- 钟镇涛-《百分百钟镇涛》首批限量版SACD-ISO
- 群星《继续微笑致敬许冠杰》[低速原抓WAV+CUE]
- 潘秀琼.2003-国语难忘金曲珍藏集【皇星全音】【WAV+CUE】
- 林东松.1997-2039玫瑰事件【宝丽金】【WAV+CUE】