iOS compatible Iphonex ios10 IOS11

Source: Internet
Author: User

Suppose you have a fixed position in the title bar, and your iOS10 CSS might be written like this:

{    position: fixed;     top: 0;     Left: 0;     Right: 0;     height: 44px;     padding-top: 20px/**/}

 

        

In order to automatically adjust iphone x and other iOS11 devices, you can add them to the meta tag viewport viewport-fit="cover" :

<name= "Viewport"  content= "Width=device-width, initial-scale=1.0, Viewport-fit=cover ">

Then constant() modify the values through the CSS padding-top :

 header  { position :  fixed ;  top :  0 ;  left :  0 ;  right :  0 ;     height :  44px ; /*   Status bar height on IOS  */      Padding-top :  20px ; /*   Status bar height on IOS 11+  */  Padding-top :  constant (safe-area-inset-top) ;}

For older devices that do not know how to fix the constant() syntax, you can do a degraded processing. You can use the CSS calc() function. can also be borrowed @supports to use.

Header{position:fixed;Top:0; Left:0; Right:0;Height:44px;/*Status Bar height on IOS*/Padding-top:20px; }@supports (constant (safe-area-inset-top)){Header {/*Status Bar height on IOS 11+*/Padding-top:constant (safe-area-inset-top); }}

Original: Http://www.w3cplus.com/css/the-notch-and-css.html? W3cplus.com

iOS compatible Iphonex ios10 ios11

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.