zoukankan      html  css  js  c++  java
  • css样式匹配苹果个型号手机

    /*适配苹果X*/
    @media only screen and (device- 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) {
        .header_nav {
            top: 44px;
        }
    }
    
    /*适配苹果X smart Max*/
    @media only screen and (device- 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) {
        .header_nav {
            top: 44px;
        }
    }
    
    /*适配苹果XR */
    @media only screen and (device- 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 2) {
        .header_nav {
            top: 44px;
        }
    }
    
    @media only screen and (device- 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) {
        .header_nav {
            top: 44px;
        }
    }
    
    /*适配,6,7,8*/
    @media only screen and (device- 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) {
        
    }
    
    /*适配,6+,7+,8+*/
    @media only screen and (device- 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) {
       
    }
    
    /*适配,5*/
    @media only screen and (device- 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) {
       
    }
    
    /*适配,4*/
    @media only screen and (device- 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 2) {
     
    }

     使用js匹配处理

        // iPhone X、iPhone XS 
        var isIPhoneX = /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 3 && window.screen.width === 375 && window.screen.height === 812;
        // iPhone XS Max 
        var isIPhoneXSMax = /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 3 && window.screen.width === 414 && window.screen.height === 896;
        // iPhone XR 
        var isIPhoneXR = /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 2 && window.screen.width === 414 && window.screen.height === 896;
    
        if(isIPhoneX || isIPhoneXSMax || isIPhoneXR){
            alert("是新手机");
        }else{
            alert("否");
        }
  • 相关阅读:
    ModbusRTU模式和结束符(转)
    modbus字符串的结束符介绍
    IAR平台移植TI OSAL到STC8A8K64S4A12单片机中
    实时系统概念
    单片机的存储区范例
    如何实现返回上一个页面,就像点击浏览器的返回按钮一般
    spring项目中的定时任务实现和问题解决
    context-param与init-param的区别与作用
    Chapter 1 First Sight——16
    一个好用简单的布局空间EasyUI
  • 原文地址:https://www.cnblogs.com/gopark/p/10268084.html
Copyright © 2011-2022 走看看