最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JS實(shí)現(xiàn)仿微信支付彈窗功能

 更新時(shí)間:2018年06月25日 11:15:57   作者:Crow_Block  
這篇文章主要介紹了JS實(shí)現(xiàn)仿微信支付彈窗功能,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

先奉上效果圖

html代碼

<!DOCTYPE html> 
<html> 
  <head> 
    <title>仿手機(jī)微信支付輸入密碼界面效果</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> 
    <!-- 打開(kāi)彈窗按鈕 --> 
    <button id="myBtn">去支付</button> 
    <!-- 彈窗 --> 
    <div id="myModal" class="modal"> 
      <!-- 彈窗內(nèi)容 --> 
      <div class="modal-content"> 
        <div class="paymentArea"> 
          <div class="paymentArea-Entry"> 
            <div class="paymentArea-Entry-Head"> 
              <img src="images/xx_03.jpg" class="close" /> 
              <img src="images/jftc_03.png" class="useImg"> 
              <span class="tips-txt">請(qǐng)輸入支付密碼</span> 
            </div> 
            <div class="paymentArea-Entry-Content"> 
              <div class="pay-name">測(cè)試商品</div> 
              <div class="pay-price">¥88.88</div> 
            </div> 
            <ul class="paymentArea-Entry-Row"></ul> 
          </div> 
          <div class="paymentArea-Keyboard"> 
            <h4> 
              <img src="images/jftc_14.jpg" height="10" /> 
            </h4> 
            <ul class="target"> 
              <li> 
                <a>1</a> 
                <a>2</a> 
                <a>3</a> 
              </li> 
              <li> 
                <a>4</a> 
                <a>5</a> 
                <a>6</a> 
              </li> 
              <li> 
                <a>7</a> 
                <a>8</a> 
                <a>9</a> 
              </li> 
              <li> 
                <a>清空</a> 
                <a> 0 </a> 
                <a>刪除</a> 
              </li> 
            </ul> 
          </div> 
        </div> 
      </div> 
    </div> 
  </body> 
</html> 

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; 
        /* 默認(rèn)隱藏 */ 
        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 
      } 
      /* 彈窗內(nèi)容 */ 
      .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; 
      } 
      /* 關(guān)閉按鈕 */ 
      .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; 
      } 
      /* 添加動(dòng)畫(huà) */ 
      @-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

//定義根目錄字體大小,通過(guò)rem實(shí)現(xiàn)適配 
      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'); 
      // 打開(kāi)彈窗的按鈕對(duì)象 
      var btn = document.getElementById("myBtn"); 
      // 獲取 <span> 元素,用于關(guān)閉彈窗 that closes the modal 
      var span = document.getElementsByClassName("close")[0]; 
      /*創(chuàng)建密碼輸入框*/ 
      var entryArea = document.querySelector(".paymentArea-Entry-Row"); 
      for(var i = 0; i < 6; i++) { 
        var li = document.createElement("li"); 
        entryArea.appendChild(li); 
      } 
      /*鍵盤(pán)操作*/ 
      var doms = document.querySelectorAll('ul li a'); 
      var entryLis = document.querySelectorAll(".paymentArea-Entry-Row li"); 
      var pwds = ""; //存儲(chǔ)密碼 
      var count = 0; //記錄點(diǎn)擊次數(shù) 
      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: 
                /*通過(guò)判斷點(diǎn)擊次數(shù) 向輸入框填充內(nèi)容*/ 
                if(count < 6) { 
                  /*創(chuàng)建一個(gè)圖片對(duì)象 插入到方框中*/ 
                  var img = new Image(); 
                  img.src = "images/dd_03.jpg"; 
                  entryLis[count].appendChild(img); 
                  /*為存儲(chǔ)密碼的對(duì)象賦值*/ 
                  if(pwds == "") { 
                    pwds = txt; 
                  } else { 
                    pwds += txt; 
                  } 
                  count++; 
                  if(pwds.length == 6) { 
                    location.; 
                  } 
                } else { 
                  return; 
                  alert("超出限制") 
                } 
            } 
          }); 
        }(doms[i], i); 
      } 
      // 點(diǎn)擊按鈕打開(kāi)彈窗 
      btn.onclick = function() { 
        modal.style.display = "block"; 
      } 
      // 點(diǎn)擊 <span> (x), 關(guān)閉彈窗 
      span.onclick = function() { 
        modal.style.display = "none"; 
        if(count != 0) { 
          for(var i = 0; i < entryLis.length; i++) { 
            entryLis[i].innerHTML = ""; 
          } 
          pwds = ""; 
          count = 0; 
        } 
      } 
      // 在用戶點(diǎn)擊其他地方時(shí),關(guān)閉彈窗 
      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; 
        } 
        } 
      } 
      /*開(kāi)關(guān)鍵盤(pán)*/ 
      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"; 
      }) 

總結(jié)

以上所述是小編給大家介紹的JS實(shí)現(xiàn)仿微信支付彈窗功能,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • 微信小程序 JS動(dòng)態(tài)修改樣式的實(shí)現(xiàn)方法

    微信小程序 JS動(dòng)態(tài)修改樣式的實(shí)現(xiàn)方法

    這篇文章主要給大家介紹了關(guān)于微信小程序JS動(dòng)態(tài)修改樣式的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2018-12-12
  • JS實(shí)現(xiàn)點(diǎn)擊拉拽輪播圖pc端移動(dòng)端適配

    JS實(shí)現(xiàn)點(diǎn)擊拉拽輪播圖pc端移動(dòng)端適配

    本文通過(guò)實(shí)例代碼給大家介紹了JS點(diǎn)擊拉拽輪播圖pc端移動(dòng)端適配 ,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-09-09
  • js實(shí)現(xiàn)簡(jiǎn)單日歷效果

    js實(shí)現(xiàn)簡(jiǎn)單日歷效果

    這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)簡(jiǎn)單日歷效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-05-05
  • Bootstrap CSS組件之導(dǎo)航條(navbar)

    Bootstrap CSS組件之導(dǎo)航條(navbar)

    這篇文章主要為大家詳細(xì)介紹了Bootstrap CSS組件之導(dǎo)航條(navbar),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-12-12
  • 一步一步封裝自己的HtmlHelper組件BootstrapHelper(二)

    一步一步封裝自己的HtmlHelper組件BootstrapHelper(二)

    一步一步封裝自己的HtmlHelper組件:BootstrapHelper,系列文章第二篇,感興趣的小伙伴們可以參考一下
    2016-09-09
  • JavaScript如何正確聲明和使用變量詳細(xì)代碼實(shí)例

    JavaScript如何正確聲明和使用變量詳細(xì)代碼實(shí)例

    變量是程序在內(nèi)存中申請(qǐng)的一塊用來(lái)存放數(shù)據(jù)的空間,下面這篇文章主要給大家介紹了關(guān)于JavaScript如何正確聲明和使用變量的相關(guān)資料,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-07-07
  • 小程序點(diǎn)餐界面添加購(gòu)物車(chē)左右擺動(dòng)動(dòng)畫(huà)

    小程序點(diǎn)餐界面添加購(gòu)物車(chē)左右擺動(dòng)動(dòng)畫(huà)

    這篇文章主要介紹了小程序點(diǎn)餐界面添加購(gòu)物車(chē)左右擺動(dòng)動(dòng)畫(huà),當(dāng)用戶點(diǎn)擊添加到購(gòu)物車(chē)后會(huì)有一個(gè)左右擺動(dòng)的購(gòu)物車(chē)提示效果,代碼簡(jiǎn)單易懂,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
    2020-09-09
  • avalonjs制作響應(yīng)式瀑布流特效

    avalonjs制作響應(yīng)式瀑布流特效

    瀑布流主要應(yīng)用在圖片展示頁(yè)面上。如果有一大批圖片需要展示,原始圖片尺寸不一致,又希望每張圖片都能不剪裁,完整顯示,那么就要給圖片規(guī)定一個(gè)寬度,解放它們的高度。利用網(wǎng)頁(yè)高度不限這個(gè)特性,充分利用頁(yè)面的空間,盡可能的展示多的圖片。下面我們就來(lái)詳細(xì)探討下
    2015-05-05
  • javascript 緩沖運(yùn)動(dòng)框架的實(shí)現(xiàn)

    javascript 緩沖運(yùn)動(dòng)框架的實(shí)現(xiàn)

    這篇文章主要介紹了javascript 緩沖運(yùn)動(dòng)框架的實(shí)現(xiàn)的相關(guān)資料,希望通過(guò)本能幫助到大家,實(shí)現(xiàn)這樣類(lèi)似的功能,需要的朋友可以參考下
    2017-09-09
  • canvas繪制一個(gè)常用的emoji表情

    canvas繪制一個(gè)常用的emoji表情

    本文主要介紹了canvas繪制一個(gè)常用的emoji表情的示例代碼。具有很好的參考價(jià)值,下面跟著小編一起來(lái)看下吧
    2017-03-03

最新評(píng)論

海晏县| 江源县| 原平市| 辰溪县| 阿拉尔市| 开鲁县| 新民市| 辽中县| 台中县| 天津市| 镇沅| 黄陵县| 越西县| 准格尔旗| 岑巩县| 宜黄县| 新民市| 武汉市| 汽车| 鄂州市| 武邑县| 忻城县| 福清市| 榆林市| 舒兰市| 衡东县| 丹棱县| 略阳县| 嘉定区| 赤峰市| 西峡县| 黔江区| 张家川| 宜兰县| 江西省| 华阴市| 本溪| 枣庄市| 巧家县| 教育| 藁城市|