Iphone safari does not support position fixed solution

Source: Internet
Author: User

The requirement is that the navigation of many pc web pages is fixed, such as google's homepage. Now we need to move this fixed navigation to mobile web, and naturally we will think of position: fixed; bottom: 0. It works normally in android, but problems may occur in iphone safari. When the scroll bar is rolling, the navigation bar will appear at the top of the screen, black and uncoordinated. Many people recommend iscroll, jquery mobile, and other frameworks, but sometimes it may take a long time to read the framework source code for secondary development. After a period of research, we found a solution, which is relatively simple, but still not as effective as pc web.
Copy codeThe Code is 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 key is the implementation of the following statement.
$ ("# Fixnav" ).css ({top: window. innerHeight + window. scrollY-$ ("# fixnav"). outerHeight ()});
});
</Script>

However, the latest ios5 supports position: fixed, which brings the gospel to the majority of web Front-end developers.
Author: qingliuyu

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.