html输入两次自动弹框,html页面中的输入框点击后,被弹出的输入法遮住了。

html页面中的输入框点击后,被弹出的输入法遮住了

使用了scrollIntoView,iOS上可以生效,安卓上没作用,代码如下

相关代码

html, body {

height: 100%;

padding: 0;

margin: 0;

}

header {

position: fixed;

top: 0;

left: 0;

z-index: 9999;

width: 100%;

height: 50px;

line-height: 50px;

font-size: 18px;

text-align: center;

background: #ccc;

}

main {

position: absolute;

top: 50px;

bottom: 10px;

left: 20px;

width: 100%;

margin-bottom: 50px;

/* 使之可以滚动 */

overflow-y: scroll;

/* 增加该属性,可以增加弹性,是滑动更加顺畅 */

-webkit-overflow-scrolling: touch;

}

footer {

position: absolute;

bottom: 0;

left: 0;

width: 100%;

height: 50px;

line-height: 50px;

text-align: center;

background: #666;

border-top: 1px solid #e6e6e6;

}

footer input {

display: inline-block;

width: 90%;

height: 20px;

font-size: 14px;

outline: none;

border: 1px solid #e6e6e6;

border-radius: 5px;

}

This is the header

Welcome to

  • Today
  • is
  • Sunday
  • And
  • I
  • have
  • to
  • go
  • to
  • work
  • tomorrow
  • Today
  • is
  • Sunday
  • And
  • I
  • have
  • to
  • go
  • to
  • work
  • tomorrow

$(function() {

$('input').on('click', function () {

var target = this;

// 使用定时器是为了让输入框上滑时更加自然

setTimeout(function(){

target.scrollIntoView(true);

},100);

});

})

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值