Problem: Under Mobile Firefox browsing, the input box keyboard masks
Solution:
? Element.scrollintoview (): Let elements scroll to the viewable area
? Parameter: True the top of the object is aligned with the top of the current window
???? False the bottom of the object is aligned with the top of the current window
The code is as follows:
<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8" /><Metaname= "Viewport"content= "Width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"><title>Mobile Input Method block input box</title><style>input{width:100%;Line-height:1.5rem;Border:1px solid Red; }. Block-fill{Height:500px; } </style></Head><Body> <DivID= "Main"> <DivID= "value"></Div> <!--Placeholder Div - <Divclass= "Block-fill"></Div> <!--need to focus - <inputID= "Input"type= "text"></input> </Div></Body><Script>
Window.onload=function () {
//Get page Heightvarclientheight=Document.body.clientHeight; varFocuselem=document.getElementById ('input'); varValueelem=document.getElementById ("value"); //Setting the monitoring focus eventDocument.body.addEventListener ("Focus", function(e) {Focuselem.scrollintoview (false); }, true);
//Setting the Listening window change TimeWindow.addeventlistener ("Resize", function() valueelem.innerhtml="focues Resize:"+Document.body.clientHeight+"; screenheight="+clientheight; if(Focuselem&&Document.body.clientHeight<clientheight) {//use the scrollIntoView method to control the input boxFocuselem.scrollintoview (false); } });
}
</ Script >
</ HTML >
Mobile Input Method block input box