JS 根据屏幕分辨率或屏幕宽度分别设置不同的样式

版权声明:JiahaoZhang原创文章,转载请注明出处 https://blog.csdn.net/GrootBaby/article/details/87360466
//判断屏幕高度,根据屏幕高度设置样式
    var body_height=$(window).height();
    if(body_height > 800){
        $(".index_main").addClass('body_height');
    }else{
        $(".index_main").removeClass('body_height');
    }
//判断屏幕分辨率,根据屏幕分辨率设置样式
    if (screen.width > 1180) {
        $("html").removeClass("screen1");
    } else {
        $("html").addClass("screen1");
    }

//根据屏幕的高度和内容的高度设置样式    
    var win=$(window).height();
    var body=$("body").height();
    if(win < body){
        alert(2);
    }
    console.log(win, body);

猜你喜欢

转载自blog.csdn.net/GrootBaby/article/details/87360466