如何在css文件中忽略媒体查询? [英] How can i ignore media queries in css file?

查看:710
本文介绍了如何在css文件中忽略媒体查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个web项目使用css文件与媒体查询。
其中一个页面正在使用相同的css文件,但我不想让它使用此css文件上的媒体查询。如何忽略它们?

I have a web project that use css file with media queries. one of the page is using the same css file but i don't want it to use the media queries on this css file. how can i ignore them?

推荐答案

如果你想忽略媒体查询 - 因为某种原因),那么一个简单的方法是将将所有媒体查询移动到CSS文件的顶部

If you want to ignore the media queries (and don't want to just comment them out -for some reason) then an easy way to do this is to move all the media queries to the top of the CSS file.

方式,相同的类将覆盖媒体查询中的样式。例如:

This way, the same classes will override the styles in the media queries. eg:

@media (max-width: 600px) { /* or whatever the media query is */
  .class {
    /*styles here */
  }
}
.class {
/*styles here */
}

或者,如果上面的方法不可能,你可以
strong>到选择器(媒体查询选择)例如:

Alternatively, (if the above method isn't possible), you could add specificity to the selectors (which the media queries select) eg:

.class.class {   /* <-- added specificity */
  /*styles here */
}

@media (max-width: 600px) { /* or whatever the media query is */
  .class {
    /*styles here */
  }
}

现在.class选择器将覆盖 媒体查询,媒体查询将被忽略。

Now the .class selecter will override the media query and the media query will be ignored.

这篇关于如何在css文件中忽略媒体查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆