The background of the problem arises:
The problem of cursor misalignment in the input position:fixed popup box in IOS11
Solution Solutions
First, the design of interaction is best not to let the pop-up window appear in the input box;
Second, the front-end processing of this compatibility scenario ideas:
1, judging mobile phone models:Android or iOS ios11 or iOS other
/*ver is iOS version, if Android ver is not an array */
var ver = (navigator.appversion). Match (/os (\d+) _ (\d+) _? ( \d+)?/); if (Array.isarray (ver)) { = parseint (ver[1);}
2. Determine where the popup box appears
A, click on the event will contain input pop-up box position:fixed changed to position:absolute
b, calculate the position of the pop-up box, if Clickbutton on the top half of the screen, keep the popover on top of the screen, if the Clickbutton is below half the screen, keep the pop-up box in the bottom of the screen
/*
#get_award 's Clickbutton.
. Tan_box is a popup box
*/
$("#get_award"). Click (function () {varTop = $ ( This). Position (). Top;/*Click the opposite of the button from the top of the screen*/ varScrollTop = $ (document). ScrollTop ();/*position of scroll bar*/ varwindow_height = $ (window). Height ();/*the visible height of the screen*/ varBox_height = $ (". Tan_box"). Height ();/*the height of the bullet frame*/Top1= Top-scrolltop; Window_height= window_height/2; if(top1<window_height) { if(top1<box_height/2){ varTOP2 =top+ -+box_height/2 }Else{ varTOP2 = window_height+ (top+ -)/2+box_height/2 } $(". Tan_box"). CSS ("Top", TOP2); }Else{ if(window_height-top1<box_height/2){ varTOP2 = top- --box_height/2 }Else{ varTOP2 = (top+ -)/2+box_height/2 } $(". Tan_box"). CSS ("Top", TOP2); }})
Author By:hgq Tuantuan
The problem of cursor misalignment in the input position:fixed popup box in IOS11