Keyboard occlusion (iOS system) with input on the bottom of the page-attached solution

Source: Internet
Author: User

On the project to make a message reply box.
Similar to this with a div set in the outside of input, click the button, the Div appears, located at the bottom of the page. and input gets the focus and automatically pops up the system keyboard.

However, in the development of the discovery, in the iOS system this div is always covered by the keyboard, has used a high-padded div box approach, naïve thought can make it move up, but found no use, need to manually pull up to come out.

Looked for a long time, to see many people on the internet died on this issue.

A more reliable answer was found on the know-how.
The reason is that fixed positioning plus bottom:0 in iOS invalid, someone suggested is to change the flexible layout, someone suggested JS control.

At first I also used the JS control, but found that the effect is not very good. Sometimes the first click, or the input box will be covered by the problem, you must manually swipe up, the div pulled out, click again, will not be obscured ... I don't know why ....

And there is no such problem on Android, it only appears on iOS and is also related to the version of the system. It used scrollIntoView() to be a lot easier to use, but then the reaction was obscured. I found that it was also related to the iOS version of the system. After referring to the answers on each road, I found a more reliable and eclectic approach. is to get the height of HTML or body, Then click on the scroll bar to scroll to the bottom.

    varScrollHeight= $(' HTML ').prop("ScrollHeight");    varTarget= Document.getElementById("Comment-content");     Target.Focus();     //timer is used to make the input box slide more naturally    SetTimeout(function(){        //target.scrollintoview (true);        //target.scrollintoviewneeded ();        $('. Add-comment ').Animate({scrolltop:ScrollHeight},  -);    }, -);

Commented out is the method used previously, in this way, with the setting html of labels and body labels height:100% and overflow: hidden to use more crisp ... But now that I have switched to it, I feel like it's scrollTop all the same, and I deleted it.

Keyboard occlusion (iOS system) in the bottom input of the page-included solution

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.