html - 媒体查询最大宽度在 Firefox 中不起作用

标签 html css media-queries

我想对最大宽度使用媒体查询。它在 Chrome 上运行良好,但在 Firefox 上却不行,为什么?

jsfiddle code

CSS

.box {
    width: 150px;
    height: 150px;
    background-color: blue;
}

@media screen and(max-width: 400px){    
    .box {
        background-color: red;
    }
}

最佳答案

你的语法有误,and(max-width)之间需要一个空格

见下文

@media screen and (max-width: 400px){
    .box {
        background-color: red;
    }
}

JSFIDDLE

关于html - 媒体查询最大宽度在 Firefox 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16866595/

相关文章:

JavaScript 媒体查询 : How to run script according to the screen width?

javascript - 在 cookie 中存储多维数组?

javascript - 可以在不使用 "for=id"的情况下将标签与复选框相关联吗?

css - 使用@supports selector() 尽管 Sass 不支持它

jquery - 将 bootstrap div 彼此对齐

css - 使用 css 对齐动态生成的元素

css - 为什么只有我的大型媒体查询有效?

javascript - 如何在 owlCarousel slider 内容上添加动画

html - 如何在不使用 "polygon"的情况下获得三 Angular 形布局

html - margin-left 不与 auto 合并