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