Make entire CSS sheet !important

☆樱花仙子☆ 提交于 2020-01-12 06:38:47

问题


Is there a way to make an entire CSS Style sheet take precedence over another? I know you can do the !important but can I do that with one line rather than modify all thousand properties on the sheet?

Thanks!


回答1:


Make sure the stylesheet you want is called last (or a specific style you want is called last). For example, using this:

span { color: red; }
span { color: blue; }

...will turn all text in <span>'s blue. Take a look here.




回答2:


Rules with identical specificity that come later will overrule previous ones, so if both style sheets contain the identical selectors, you should be able to do this by just loading the one before the other.

If they contain different selectors, like

#navigation h3 { color: red }

and

.mainpage .navmenu h3 { color: blue }

you are likely to get specificity conflicts. The only blanket solution for that is indeed !important (although that is really, really terrible architecturally. Are you sure you need this? Maybe explain why, it's possible somebody is able to come up with a better solution.)

There is, however, no single-line directive to elevate the "importance" of one style sheet over the other.



来源:https://stackoverflow.com/questions/5526510/make-entire-css-sheet-important

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!