The demand is like this, many PC Web pages navigation is fixed, such as Google's homepage, now to move the fixed navigation to the mobile web, it is natural to think of position:fixed; Bottom:0,android under normal operation, but there will be a problem in the iphone safari, when the scroll bar scrolling, the navigation bar will appear above the screen, dark piece, very uncoordinated. Many people recommend frameworks such as Iscroll, jquery Mobile, and so on, but sometimes they don't work well or have to read the framework code for two of times, which can take a long time to develop. After a period of research, found a solution, relatively simple, but the effect is not comparable to the PC Web.
Copy Code code as follows:
<div id= "Fixnav" style= "Position:absolute; z-index:1000; height:50px; opacity:0.9; " >nav</div>
<script type= "Text/javascript" >
$ (window). Scroll (function () {
The point is the implementation of the following statement
$ ("#fixnav"). CSS ({top:window.innerHeight + window.scrolly-$ ("#fixnav"). Outerheight ()});
});
</script>
But the latest IOS5 has supported position:fixed, bringing the gospel to the vast Web front-end developers.
Author: Clean Fish