Mobile keyboard occlusion input problem

When developing a mobile project, the test asks optimization problems, namely:

 When the input  gets the focus and the system virtual keyboard pops up, the  input  is blocked by the keyboard (PS: This problem only exists on Android phones, and the ios system handles it automatically).

The solution is:

When the  input  gets the focus, get   the distance thisTop from the position of the  input on the page relative to the half of the screen, then  add a  div to the body with a  height of thisTop+50, and then set the scrollTop of the page to thisTop+50 to ensure that the input gets the focus When the time is in the middle of the screen;

After the input is complete, hide the dynamically added  div  .

 

If there are any inaccuracies in the expression, please correct me, welcome to add, thank you for reading!

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325207515&siteId=291194637
Recommended