簡體   English   中英

媒體查詢只能在Chrome瀏覽器中使用,而不能在Safari(例如Firefox)中使用?

[英]Media queries working in chrome but not safari, ie, or firefox?

這讓我發瘋,我似乎找不到媒體查詢的問題,但是除了ios 7和chrome上的移動瀏覽器之外,它在任何瀏覽器中均不起作用。 我認為這是一些瘋狂的語法錯誤,但我又找不到任何東西。 順便說一句,媒體查詢都在它們自己的文件(mediaqueries.css)中,並鏈接在所有樣式表的底部。

@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%;
    }
}

我剛剛使用W3C CSS Validator驗證了您的代碼,並注意到“和”引起了問題,基本上,您需要在“和”之后給一個空格。

@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%;
        }
    }

也許您應該使用min-width而不是max-width 您的樣式可能總是可見/不可見,因為某個地方總是有最大寬度。

雖然語法不錯,但也根據html結構檢查層次結構是否合適。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM