美文网首页
小程序-input键盘弹出导致页面上移问题

小程序-input键盘弹出导致页面上移问题

作者: HCL黄 | 来源:发表于2019-11-11 17:29 被阅读0次

    如图,在部分手机当输入框获取焦点到失去焦点,会导致底部底部view上移偏差

    C7DEA46C-3A35-45BE-9416-33C37F1B09A6.png

    首先自定义弹框组件布局如下图

    • payPopView.js


      E5AA7AD9-36BE-4EF6-906E-6BCFF2674C7B.png
    主要是获取焦点方法处理
    1AF3DFB6-D5F3-4E65-A465-CDEB5D8E5291.png
    31B33A76-A4E2-40B5-9852-532D13179934.png
    • payPopView.json


      F9E5D5B7-075E-4ADC-8D3E-E8C2D9B06BA4.png
    • payPopView.ttml


      1323A37B-213B-48F1-91CF-5BAD7137E366.png
      1D3C08A2-2C34-4658-8177-E482B24235B1.png
    • payPopView.ttss就没啥好说的了
    /* components/payPopView.ttss */
    .popV {
      display: flex;
      justify-content: center;
    }
    .popV-mask {
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.4);
      display: block;
      position: fixed;
      z-index: 1000;
    }
    .popV-content{
      bottom: 0rpx;
      background: white;
      display: flex;
      position: fixed;
      z-index: 1001;
      flex-direction: column;
    
      width:750rpx;
      height:884rpx;
      background:rgba(255,255,255,1);
      border-radius:40rpx 40rpx 0rpx 0rpx;
    }
    .popCnt-closeV {
      display: flex;
      align-items: center;
      justify-content: flex-end;
    
    }
    .popCnt-closeV-img {
      right: 0;
      width: 44rpx;
      height: 44rpx;
    
      margin-top: 30rpx;
      margin-right: 40rpx;
      margin-bottom: 16rpx;
    }
    .popCnt-cntV {
      display: flex;
      flex-direction: column;
    
      margin: 0rpx 40rpx;
    }
    .cntV-top {
      display: flex;
    
      width: 670rpx;
      height: 186rpx;
    
    }
    .cntV-top-bg {
      width: 670rpx;
      height: 186rpx;
      background:rgba(49,49,49,1);
      box-shadow:0rpx 4rpx 16rpx 0px rgba(0,0,0,0.2);
      border-radius:20rpx;
    
    }
    
    .cntV-line {
      background-color: #E1E1E1;
      width:670rpx;
      height:2rpx;
    
      margin-bottom: 38rpx;
    }
    /* 输入手机号 */
    .cntV-phone {
      background:rgba(245,245,245,1);
    
      display: flex;
      flex-direction: row;
      justify-content: space-between;
    
      height: 88rpx;
    }
    .cntV-phone-left {
      display: flex;
      flex-direction: row;
    
      /* justify-content: center; */
      align-items: center;
    }
    .cntV-phoneL-img {
      width: 36rpx;
      height: 36rpx;
    
      margin-left: 20rpx;
      margin-right: 16rpx;
    }
    .cntV-phoneL-text {
      font-size:28rpx;
      font-family:PingFangSC-Regular,PingFang SC;
      font-weight:400;
      color:rgba(102,102,102,1);
      line-height:32rpx;
    
      white-space: nowrap;
    }
    .cntV-phone-right {
      display: flex;
      align-items: center;
    
      margin-right: 20rpx;
    }
    .cntV-phoneR-text {
      font-size:28rpx;
      font-family:PingFangSC-Regular,PingFang SC;
      font-weight:400;
      color:rgba(153,153,153,1);
      line-height:40rpx;
    
      text-align: right;
    }
    /* 验证码 */
    .cntV-code {
      display: flex;
      flex-direction: row;
    
      justify-content: space-between;
      margin-top: 22rpx;
    }
    .cntV-code-left {
      display: flex;
      flex-direction: row;
    
      justify-content: space-between;
      flex: 1;
      background:rgba(245,245,245,1);
    }
    .cntV-code-right {
      width:186rpx;
      height:88rpx;
      background:rgba(235,202,144,1);
    
      margin-left: 24rpx;
    
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .cntV-code-rightGray {
      background:rgba(153,153,153,1);
      opacity:0.5;
    }
    .cntV-codeR-text {
      font-size:28rpx;
      font-family:PingFang-SC-Bold,PingFang-SC;
      font-weight:bold;
      color:rgba(255,255,255,1);
      line-height:40rpx;
    }
    /* 确认支付 */
    .cntV-payBtn {
      width:670rpx;
      height:98rpx;
      background:rgba(204,204,204,1);
      box-shadow:0rpx 4rpx 14rpx 0rpx rgba(220,220,220,1);
      border-radius:49rpx;
    
      margin-top: 60rpx;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .cntV-payBtn-enable {
      background:linear-gradient(180deg,rgba(255,233,195,1) 0%,rgba(222,192,140,1) 100%);
      box-shadow:0px 4px 14px 0px rgba(237,215,176,1);
    }
    .cntV-payBtn-text {
      font-size:40rpx;
      font-family:PingFang-SC-Bold,PingFang-SC;
      font-weight:bold;
      color:rgba(49,49,49,1);
      line-height:56rpx;
    }
    

    index布局如下图

    • index.js


      A0E28555-7BD9-4A0D-95C3-95BEE9D9CF83.png
    • index.json


      0F323EFB-9AFF-43EE-8658-868B89D11EE8.png
    • index.ttml


      627EBB15-6559-4E5F-B92C-E918519C2777.png
    • index.ttss


      7BD8A15B-5186-4414-91A6-C72A93F0C15B.png

    相关文章

      网友评论

          本文标题:小程序-input键盘弹出导致页面上移问题

          本文链接:https://www.haomeiwen.com/subject/ziytictx.html