iphone Safari does not support position fixed solution _javascript tips

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.