Solve the problem of compressing the layout of the background or percent position when the Android phone keyboard pops up

Source: Internet
Author: User

Do mobile page often encounter the following cases, in the background of the page to write a form, and the bottom in order to adapt to different mobile phones also have to use absolute positioning, because the container height is usually set to 100%, then on the Android phone on the soft keyboard window will be the background picture and other things squeeze up, the solution is as follows:

Define a large container as a fixed layout in CSS styles

  . Wrap{ position:fixed;  left:0; top:0; }

In JS to force the height of the page to him, the equivalent of automatic open

var // querying the width of a device var // querying the device's height $ (//$ (". Wrap"). Height (y);//Assign the width and height of the device to the page

Solve the problem of compressing the layout of the background or percent position when the Android phone keyboard pops up

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.