Mobile software disk masking input box problem

Source: Internet
Author: User

First, solve the problem that the soft keyboard affects the layout first:

Soft keyboard Popup will change the height of the viewable area of the browser, Android will trigger the Window.resize event, iOS will not trigger, so if the layout of the page element is based on the size of the window, there will be layout confusion, such as the body of the height:100% and so on,

So you need to execute this code after the page is initialized (the height of the body is fixed so that he doesn't adapt)

  $(document).ready(function() {

    $( ‘body‘ ).height($( ‘body‘ )[0].clientHeight);   });Second, distinguish the input box is obscured by the type of the input box height of the screen is the highest visual area of the page is half, that is, the width of 1/2 mobile phone, so if all the input boxes in the upper part of the page, there is no soft keyboard occlusion input box problem (1), the input box at the bottom of the page and the first input The input box group is positioned to the bottom of the page with absolute positioning.    When the soft keyboard pops up, it automatically pops up all the input boxes (2), the total height of the input frame group is greater than the 1/2 page height. Do focuse monitoring events for each input box or listen directly to the Window.resize event (if you are using a third-party input method, you need to put the following code inside the time function) document.activeelement. scrollIntoView(false); document.activeElement.scrollIntoViewIfNeeded();        orfunction Scrollt () {

$ ("Html,body"). Animate ({scrolltop: $ (". Fi_now"). Offset (). Top}, 300);

}

    

Reference URL:

Deep understanding of scrolling scroll:https://www.cnblogs.com/xiaohuochai/p/5831640.html

Mobile software disk masking input box problem

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.