美文网首页
HTML5如何优雅的适配iPhoneX

HTML5如何优雅的适配iPhoneX

作者: 桥下醉翁 | 来源:发表于2020-04-08 16:51 被阅读0次

    1、首先在meta属性中,增加viewport-fit=cover

    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover" />
    

    2、使用响应式,设置iPhoneX页面效果,但是可能误伤部分Android机

    @media only screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) {
    // iPhoneX
    }
    @media only screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) {
    // iPhoneX Max
    }
    @media only screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) {
    // iPhoneXR
    }
    

    相关文章

      网友评论

          本文标题:HTML5如何优雅的适配iPhoneX

          本文链接:https://www.haomeiwen.com/subject/yiotmhtx.html