iPhone X / 8 / 8 Plus CSS media queries

后端 未结 5 2111
猫巷女王i
猫巷女王i 2020-12-02 05:02

What are the CSS media queries corresponding to Apple\'s new devices ? I need to set the body\'s background-color to change the X\'s safe area back

5条回答
  •  长情又很酷
    2020-12-02 05:16

    iPhone X

    @media only screen 
        and (device-width : 375px) 
        and (device-height : 812px) 
        and (-webkit-device-pixel-ratio : 3) { }
    

    iPhone 8

    @media only screen 
        and (device-width : 375px) 
        and (device-height : 667px) 
        and (-webkit-device-pixel-ratio : 2) { }
    

    iPhone 8 Plus

    @media only screen 
        and (device-width : 414px) 
        and (device-height : 736px) 
        and (-webkit-device-pixel-ratio : 3) { }
    


    iPhone 6+/6s+/7+/8+ share the same sizes, while the iPhone 7/8 also do.


    Looking for a specific orientation ?

    Portrait

    Add the following rule:

        and (orientation : portrait) 
    

    Landscape

    Add the following rule:

        and (orientation : landscape) 
    



    References:

    • https://webkit.org/blog/7929/designing-websites-for-iphone-x/
    • https://developer.apple.com/ios/human-interface-guidelines/visual-design/adaptivity-and-layout/
    • https://developer.apple.com/ios/human-interface-guidelines/overview/iphone-x/
    • https://mydevice.io/devices/
    • http://viewportsizes.com/mine/

提交回复
热议问题