简体   繁体   English

具体说明哪些外部CSS文件会覆盖哪些

[英]Specific which external CSS files overrides which

I'm working on a web project that uses SOY templates and SASS. 我正在使用SOY模板和SASS的Web项目上工作。 For reasons, I'm not able to get SASS preprocessor to continue working it with SASS but all the CSS and SCSS files are present and I can look at them just not modify. 由于某些原因,我无法让SASS预处理器继续与SASS一起使用,但是所有CSS和SCSS文件都存在,并且我可以不修改地查看它们。

I currently have a custom CSS file that I'm working on, however some things are getting override by the CSS file the SASS created. 我目前正在使用一个自定义CSS文件,但是有些东西被SASS创建的CSS文件覆盖。 For example, !important and generally just making it harder to add my own CSS when some things are getting override. 例如, !important通常会使某些事情被覆盖时,增加我自己的CSS的难度。

So my question is, is there a way to specific which CSS file gets called last so that one can overrides all the previous CSS? 所以我的问题是,有没有一种方法可以确定最后调用哪个CSS文件,以便可以覆盖以前的所有CSS?

I'd suggest you put your CSS file after other CSS files. 我建议您将CSS文件放在其他CSS文件之后。 And furthermore, you need to read about the precedence rule: https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity 而且,您需要阅读有关优先级规则的信息: https : //developer.mozilla.org/en-US/docs/Web/CSS/Specificity

  1. There can be different precedence rules that might override your CSS. 可能有不同的优先规则可能会覆盖您的CSS。
  2. Inspect the element in the browser developer tools and you can see if your CSS selector is preceded by another stronger rule eg .parent > .child .element{ color: #000} and then you can copy that CSS selector and use it in your css file to avoid !important 检查浏览器开发人员工具中的元素,您可以查看CSS选择器是否.parent > .child .element{ color: #000}另一个更强的规则,例如.parent > .child .element{ color: #000} ,然后您可以复制该CSS选择器并在CSS中使用它避免使用文件!important

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

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