如何使CSS文件比另一个CSS文件更重要? [英] How to make CSS file more important than another CSS file?
问题描述
我想要 css.css
中的所有类,标签和ID覆盖 bootstrap.min.css
不重复 bootstrap.min.css
的类,标签和ID。
I want all the Classes,Tags and Ids within css.css
overwritten over bootstrap.min.css
without repeating the Classes,tags and Ids of bootstrap.min.css
.
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/css.css" rel="stylesheet">
推荐答案
您可以将引用放在 css.css
You can place the reference to css.css
after the reference to bootstrap.min.css
, but this is just one factor in the process of resolving how CSS rules will be applied. Adding !important
, which is generally a symptom of wrong design, is just yet another factor: an !important
rule in an earlier file may override your !important
rule, if its selector has higher specificity.
要覆盖CSS规则,您需要分析要覆盖的规则,并通过级联原则设置胜利的规则。
To override CSS rules, you need to analyze the rule you wish to override and set up a rule that "wins", by the cascade principles.
这篇关于如何使CSS文件比另一个CSS文件更重要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!