iPhone XR / XS / XS Max CSS media queries

前端 未结 3 887
日久生厌
日久生厌 2021-01-30 10:40

What are the correct CSS media queries used to target Apple\'s 2018 devices: iPhone XR/XS/XS Max ?

3条回答
  •  离开以前
    2021-01-30 11:25

    iPhone XR

    /* 1792x828px at 326ppi */
    @media only screen 
        and (device-width : 414px) 
        and (device-height : 896px) 
        and (-webkit-device-pixel-ratio : 2) { }
    

    iPhone XS

    /* 2436x1125px at 458ppi */
    @media only screen 
        and (device-width : 375px) 
        and (device-height : 812px) 
        and (-webkit-device-pixel-ratio : 3) { }
    

    iPhone XS Max

    /* 2688x1242px at 458ppi */
    @media only screen 
        and (device-width : 414px) 
        and (device-height : 896px) 
        and (-webkit-device-pixel-ratio : 3) { }
    



    Looking for a specific orientation ?

    Portrait

    Add the following rule:

        and (orientation : portrait) 
    

    Landscape

    Add the following rule:

        and (orientation : landscape) 
    



    References:

    • https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/adaptivity-and-layout/
    • https://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions

提交回复
热议问题