简体   繁体   English

我的媒体查询不起作用

[英]My media queries doesn't work

Does anyone know why my media queries code doesn't work?Thanks! 有谁知道为什么我的媒体查询代码不起作用?

@media only screen and (min-width:450px){
  .dark-blue{
    width: 25%;
  }
  .blue{
    width: 75%;
  }
}

More details in my github https://github.com/kmfb/udacityProjects/tree/master/column%20drop 更多细节在我的github https://github.com/kmfb/udacityProjects/tree/master/column%20drop

Just move the @media to the bottom of the css page. 只需将@media移到CSS页面的底部即可。
Check working example. 检查工作示例。
Cheers, 干杯,
https://jsfiddle.net/frc7r123/ https://jsfiddle.net/frc7r123/

It works, but you need to place your media query below your other CSS. 它可以工作,但是您需要将媒体查询放置在其他CSS下方。 Otherwise it won't overwrite anything. 否则它将不会覆盖任何内容。

It mostly depends on your project because at the end of the day it is all about maintenance and adding more stuff to it easily. 这主要取决于您的项目,因为归根结底,这都是关于维护和轻松添加更多内容的。

So, if you are working on a project which only has a few media queries I would suggest leaving them all at the bottom of your stylesheet but putting comments on top of it to make it explicit and also easier for you to find it later. 因此,如果您正在进行的项目中只有少数媒体查询,我建议您将它们全部保留在样式表的底部,但要在其顶部添加注释以使其明确,也便于以后查找。

However, if you know you are going to have a lot of properties meticulously defined in your media queries and also have various devices defined then I would suggest separating them out just for readability/maintenance reasons. 但是,如果您知道要在媒体查询中精心定义许多属性,并且还定义了各种设备,那么我建议您出于可读性/维护性的原因将它们分开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM