[英]Overriding all existing CSS styles?
I have one simple question that I couldn't find a definitive answer for as of yet.我有一个简单的问题,到目前为止我还找不到明确的答案。 I want to change the styling of a website that already has extensive CSS applied.
我想更改已经应用了大量 CSS 的网站的样式。 I cannot remove or edit these existing files, only add my own.
我无法删除或编辑这些现有文件,只能添加我自己的文件。 Is there a way to override all existing CSS styles, or even remove them, through a new file?
有没有办法通过新文件覆盖所有现有的 CSS 样式,甚至删除它们? Or is the only solution to override each style individually, by using more specific selectors, the
!important
keyword, and so on?或者是通过使用更具体的选择器、
!important
关键字等来单独覆盖每个样式的唯一解决方案?
I am very new to web design, so I hope you'll forgive this (maybe very simple) question.我对网页设计很陌生,所以我希望你能原谅这个(也许很简单)的问题。
yes important can override it but there are specificity overriding also.是的,重要可以覆盖它,但也有特殊性覆盖。 Example
例子
<div class="main">
<div class="test-wrapper">
<div class="box s-1 h-1">
</div>
</div>
</div>
.main .test-wrapper .box{}
if I want to override this如果我想覆盖这个
increase the specificity增加特异性
.main .test-wrapper .box.s-1{}
https://www.w3schools.com/css/css_selectors.asp https://www.w3schools.com/css/css_selectors.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.