Media queries working in chrome but not safari, ie

2019-08-05 15:50发布

This is driving me crazy, I cant seem to find a problem with the media queries but it doesnt work in any browser besides mobile safari on ios 7 and chrome. I assume that it is some crazy syntax error but again, I cant find anything. BTW, the media queries are all in their own file (mediaqueries.css) and linked on the bottom of all stylesheets.

@media screen and(max-width: 1100px) {

    #bottombar ul li{
        margin-right: 24px;
    }
}
@media screen and(max-width: 1030px) {
    #bottombar ul li{
        margin-right: 20px;
    }
}
@media screen and(max-width: 955px) {
    #bottombar ul li a{
        font-size: 15px;
    }
    #bottombar ul{
        margin-left: -25px;
    }
}
@media screen and(max-width: 925px) {
    #bottombar ul li a{
        font-size: 15px;
    }
}
@media screen and(max-width: 880px) {
    #bottombar input{
        display: none;
    }
    #alternativesearch input{
        display: block;
    }
}
@media screen and(max-width: 800px) {
    section#skills ul{
        float: none;
        /*margin: 0 auto;*/
        margin-left: -70px;
        width: 100%;
    }   
    section#skills ul h3{
        font-size: 30px;
    }
    section#skills ul li{
        font-size: 20px;
    }
    h1.catcher_title{
        margin-top: 50px;
    }
}
@media screen and(max-width: 770px) {
        #image_placeholder,#about article{
            float: none; width: 100%;
        }
        #about article{
            margin: 0;
        }
        #skills{
            margin-top: -300px;
        }
}
@media screen and(max-width: 735px) {
    h1.catcher_title{
        margin-top: 30px;
    }
    h3.catcher_title{
        margin-top: -30px;
    }
}   
@media screen and(max-width: 700px) {
    #bottombar ul li a{
        font-size: 13px;
    }
}   
@media screen and(max-width: 648px) {
    #bottombar ul li a{
        font-size: 13px;
    }
    .popup{
        width: 300px;
        margin-left: -150px;
    }
    h1.catcher_title{
        margin-top: 60px;
    }
}
/*@media screen and(min-width: 500px){
    #bottombar{
        border-top: 8px solid #16A07A;
        height: 52px;
    }
}*/ 
@media screen and(max-width: 540px){
    #bottombar ul li:last-child{
    display: block;
}
    #cart{top:20px;}
    #view_cart{top:40px;}
    #alternativesearch input:focus{
        width: 150px;
        top:25px;
    }
    #alternativesearch input{
        top:25px;
    }
    h3.catcher_title{
        margin-top: -20px;
    }
    body{margin-top: 0px;}
    #bottombar{
        height: 16px;
        top:0px;
        border: none;
        overflow: hidden;
        background: transparent;
    }
    #logo{display: none;}
    #menutoggle{
        display: block;
    }
    #bottombar ul{
        margin-left: -50px;
    }
    #bottombar ul li:nth-child(1){
        border-top: 1px solid green;
    }
    #bottombar ul li{
        width: 100%;
        /*height: 20px;*/
        margin-left: 0;
        /*background: #1C8C0F;*/
        border-bottom: 1px solid green; 
        margin-right: 0;
        text-align: center;
    }
    #bottombar ul li:hover{
        background: green;
    }
    #bottombar ul li a{
        display: block;
        font-size: 20px;
        line-height: 120%;
    }
}

2条回答
贼婆χ
2楼-- · 2019-08-05 16:12

I just validated your code with W3C CSS Validator, and noticed the "and" is causing the issue, basically you need give a space after the "and".

@media screen and (max-width: 1100px) {

        #bottombar ul li{
            margin-right: 24px;
        }
    }
    @media screen and (max-width: 1030px) {
        #bottombar ul li{
            margin-right: 20px;
        }
    }
    @media screen and (max-width: 955px) {
        #bottombar ul li a{
            font-size: 15px;
        }
        #bottombar ul{
            margin-left: -25px;
        }
    }
    @media screen and (max-width: 925px) {
        #bottombar ul li a{
            font-size: 15px;
        }
    }
    @media screen and (max-width: 880px) {
        #bottombar input{
            display: none;
        }
        #alternativesearch input{
            display: block;
        }
    }
    @media screen and (max-width: 800px) {
        section#skills ul{
            float: none;
            /*margin: 0 auto;*/
            margin-left: -70px;
            width: 100%;
        }   
        section#skills ul h3{
            font-size: 30px;
        }
        section#skills ul li{
            font-size: 20px;
        }
        h1.catcher_title{
            margin-top: 50px;
        }
    }
    @media screen and (max-width: 770px) {
            #image_placeholder,#about article{
                float: none; width: 100%;
            }
            #about article{
                margin: 0;
            }
            #skills{
                margin-top: -300px;
            }
    }
    @media screen and (max-width: 735px) {
        h1.catcher_title{
            margin-top: 30px;
        }
        h3.catcher_title{
            margin-top: -30px;
        }
    }   
    @media screen and (max-width: 700px) {
        #bottombar ul li a{
            font-size: 13px;
        }
    }   
    @media screen and (max-width: 648px) {
        #bottombar ul li a{
            font-size: 13px;
        }
        .popup{
            width: 300px;
            margin-left: -150px;
        }
        h1.catcher_title{
            margin-top: 60px;
        }
    }
    /*@media screen and (min-width: 500px){
        #bottombar{
            border-top: 8px solid #16A07A;
            height: 52px;
        }
    }*/ 
    @media screen and (max-width: 540px){
        #bottombar ul li:last-child{
        display: block;
    }
        #cart{top:20px;}
        #view_cart{top:40px;}
        #alternativesearch input:focus{
            width: 150px;
            top:25px;
        }
        #alternativesearch input{
            top:25px;
        }
        h3.catcher_title{
            margin-top: -20px;
        }
        body{margin-top: 0px;}
        #bottombar{
            height: 16px;
            top:0px;
            border: none;
            overflow: hidden;
            background: transparent;
        }
        #logo{display: none;}
        #menutoggle{
            display: block;
        }
        #bottombar ul{
            margin-left: -50px;
        }
        #bottombar ul li:nth-child(1){
            border-top: 1px solid green;
        }
        #bottombar ul li{
            width: 100%;
            /*height: 20px;*/
            margin-left: 0;
            /*background: #1C8C0F;*/
            border-bottom: 1px solid green; 
            margin-right: 0;
            text-align: center;
        }
        #bottombar ul li:hover{
            background: green;
        }
        #bottombar ul li a{
            display: block;
            font-size: 20px;
            line-height: 120%;
        }
    }
查看更多
【Aperson】
3楼-- · 2019-08-05 16:29

Maybe you should use min-width instead of max-width. It's possible that your styles are always seen/unseen because there is always a max-width somewhere.

The syntax is good though, also check if the hierarchy is good according to the html structure.

查看更多
登录 后发表回答