美文网首页程序员
css与jQuery判断是横竖屏幕的方法

css与jQuery判断是横竖屏幕的方法

作者: 10422c91aacb | 来源:发表于2019-10-08 11:04 被阅读0次

    css代码判断横竖屏

    /* 设备竖屏时调用该段css代码 */
    @media all and (orientation : portrait){
    
        .class_name{
          /*竖屏样式*/
        }
    }
    /* 设备横屏时调用该段css代码 */
    @media all and (orientation : landscape){
        .class_name{
           /*横屏样式*/
        }
    }
    

    jQuery判断横竖屏

            if (window.orientation == 90 || window.orientation == -90) {
                // Andriod横屏,iPad、iPhone竖屏
                //业务逻辑
            } else if (window.orientation == 0 || window.orientation == 180) {
                // Andriod竖屏,iPad、iPhone横屏
                //业务逻辑
            }
    

    相关文章

      网友评论

        本文标题:css与jQuery判断是横竖屏幕的方法

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