【问题标题】:Why is my CSS Media Query being ignored or overridden? (tumblr)为什么我的 CSS 媒体查询被忽略或覆盖? (微博)
【发布时间】:2013-11-22 16:31:27
【问题描述】:

这是我的 CSS:

@media screen and (max-width: 640px){
.double{width:260px;}
.double img{width:100%;height:auto;}
.title {font-size:50px;}
}

无论我如何编辑@media screen and (max-width: 640px) 属性,都没有任何效果。我也尝试过添加!important,但它不起作用。

似乎我的 @media 属性被忽略/覆盖,因为当我调整浏览器大小并检查元素(在 FireFox 上)时,使用的 CSS 仍然是 .double img{width:560px;} 而应该是 .double img {width:100%;height:auto;}

任何帮助将不胜感激! :)

Here's my Tumblr. 如果有帮助,我的 JSFiddle 是 here

【问题讨论】:

    标签: image responsive-design media-queries


    【解决方案1】:

    这只是由 .capz 类中的语法错误引起的,就在您的媒体查询之前:

    .capz {
         opacity:0;
        filter:alpha(opacity = 0);
        -webkit-transition: all 0.3s ease;
        -moz-transition: all 0.3s ease-in-out;
        -o-transition: all 0.3s ease-in-out;
        -ms-transition: all 0.3s ease-in-out;
        transition: all 0.3s ease-in-out;
        position: absolute;
        background: rgba(255,255,255; //missing closing parenthesis
        width: 100%;
        height: 100%;
        bottom:3px;
    }
    
    @media screen and (max-width: 640px){
        .double{width:260px;!important}
        .double img{width:100%!important;height:auto !important;}
        img {max-width: 100% !important;height: auto !important;}
    }
    

    (注意:在这种情况下您不再需要!important 标签)

    Updated fiddle

    【讨论】:

    • 我这几天一直在努力找出问题所在,真不敢相信我错过了这个!我现在真的觉得自己像个白痴哈哈。谢谢!! :)
    • @user2446412 很高兴为您提供帮助,如果您认为是,请将此问题设置为已回答。
    猜你喜欢
    • 2012-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-13
    • 1970-01-01
    • 1970-01-01
    • 2013-04-13
    相关资源
    最近更新 更多