html - CSS 媒体查询不改变元素?

标签 html css media-queries

我正在尝试让这个媒体查询工作...我已经更改了边框和元素颜色以及位置,所以我可以清楚地看到它何时工作但它似乎根本没有应用规则- 我错过了什么?我正在寻找空格和拼写错误,但我看不到任何...

HTML

<div id="introcontainer">
     <div id="introcontainer2">
         <div class="introbox" id="introbox1">48</div>
         <div class="introbox" id="introbox2">3</div>
         <div class="introbox" id="introbox3">£99</div>
     </div>
</div>

CSS

@media only screen and (min-width: 768px)  and (max-width: 992px) {

#introcontainer {
    width: 660px; 
    height: 134px; 
    position: absolute; left: 50%; top: 100px; 
    margin-left: -330px; border-style: dashed; border-color: red;}

.introbox {
width: 214px;
height: 130px;
background: #fffff;
opacity: 0.1;
border-radius: 4px;}
}

#introcontainer {width: 660px; height: 134px; position: absolute; left: 50%;           top: 250px; margin-left: -330px; border-style: dashed; border-color: aqua;}

#introcontainer2 {position: relative;}
.introbox {
width: 214px;
height: 130px;
background: #6666CC;
opacity: 0.5;
border-radius: 4px;
}

#introbox1 {position: absolute; left: 0px;}

#introbox2 {margin-left: auto; margin-right: auto;}
#introbox3 {position: absolute; right: 0px; top: 0px;}

最佳答案

您是否有可能忘记关闭@media? 因为当我删除:

@media only screen and (min-width: 768px)  and (max-width: 992px) {

它起作用了。

你可以在这个codepen中看到它. 也可能你的@media 减速有误?

我认为你应该把它放在你的常规 css 之后,或者改变最小/最大宽度。

关于html - CSS 媒体查询不改变元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36988293/

相关文章:

javascript - 调整浏览器大小时 Modernizr 媒体查询不起作用

android - 需要某些移动浏览器的媒体查询解决方案

html - 将表格布局转换为等效的 div

javascript - 使用图像区域作为提交

html - 表格不占用容器 CSS 的宽度

javascript - jQuery 显示 block 和淡入

javascript - 通过 jquery.ajax 重新加载后从 div 中恢复输入/选择元素

html - 如何更改 iframe 中的文件下载名称?

css - 使用 Body Zoom 时如何使图像不缩放

基于 webkit 的浏览器的 CSS 规则