Reprinted from: http://www.ithao123.cn/content-649841.html
Mobile development Imitation app head bottom fixed setting position:fixed,android2.2 above has been implemented. However, when the keypad is active, the position floating problem occurs in the iOS8 system below.
How to resolve:
Look up the data and think of several solutions
1, using Position:absolute simulation
<script type= "Text/javascript" >
Window.onscroll=function () {
$ (". Fixed"). CSS ("Top", $ (window). scrolltop ());
$ (". Foot"). CSS ("Top", $ (window). scrolltop () +$ (window). Height ());
}
</script>
Here's the problem: there's a noticeable jitter in the bottom div of the head when sliding the page.
2, judging the current get focus element is input then hide Div changed to Position:absolute
<body Onload=setinterval ("A ()", $) >
<script type= "Text/javascript" >
function A () {
if (Document.activeElement.tagName = = ' INPUT ') {
$ (". Fixed"). css ({' position ': ' absolute ', ' top ': ' 0 '});
} else {
$ (". Fixed"). CSS (' position ', ' fixed ');
}
}
</script>
Here's the problem: constantly monitoring the DOM and consuming resources. If the input number is small, you can add the onfocus event in input to better. But if it's a bottom-pinned Div, this method doesn't seem to give much force.
3, plugin Iscroll.js personal feeling is not very useful. Probably not, JQuery Mobile didn't try, and it felt like a burden.
4, the focus has come:
Just add CSS style position:fixed;top:50px to the middle part of the outer div; Bottom:50px;overflow:scroll, you can achieve results without plugins. You can copy the following code to run.
<! DOCTYPE html>
Little tricks CSS to address mobile iOS incompatible position:fixed properties without plugins