H5 page, on ios, the input box is covered by the keyboard, how to solve it?

The

1.scrollView () method does not solve the problem that
2.js cannot get the height of the soft keyboard, and ios cannot trigger the resize event

Mar.02,2021

I've studied this problem before, and under iOS, you can solve it with scrollIntoView () .

for the Android platform, I assume by default that the height of the soft keyboard will not exceed half the height of the screen, so first use clickedElement.getBoundingClientRect (). Top to calculate the height of the clicked element from the top of the screen, and if the distance is less than half the height of the screen, use scrollTop () to move it up a certain distance. Because Android does not support the scrollBy () method during testing on an Android real machine, the scrollTop () method is used.

also organized into an article and put it here: Click the input box to automatically move the page up to the top of the soft keyboard .

Menu