简体   繁体   English

忽略 css 规则值

[英]Ignore css rule value

Suppose I have a css file with the following content:假设我有一个包含以下内容的 css 文件:

p {
    color: red;
    border: 1px solid red;
}

div p {
    color: $paragraphColor;
    border: $paragraphBorder;   
}

I can inject a value into the file with replace that will override the default rule (red color or red border).我可以使用 replace 将一个值注入到文件中,该值将覆盖默认规则(红色或红色边框)。 Is there a value I can enter in place of $paragraphColor and $paragraphBorder that will make this rule ignored and the paragraph will be red or have a red border?是否有我可以输入的值来代替 $paragraphColor 和 $paragraphBorder,这将使该规则被忽略并且该段落将变为红色或具有红色边框? Of course, I can set a wrong rule, eg color: ggggggggggg;当然,我可以设置一个错误的规则,eg color: ggggggggggg; but I don't want to enter the wrong rule.但我不想输入错误的规则。

EDIT: I figured that the parameter could be property + value, for example:编辑:我认为参数可以是属性+值,例如:

div p {
    /* paragraph.color */
    /* paragraph.border */ 
}

then css file is correct and I get default values if non of them is replaced然后 css 文件是正确的,如果没有替换它们,我会得到默认值

you can use this:你可以使用这个:

color: unset !important;

I'm not sure, i understood your question.我不确定,我理解你的问题。 But i found this:但我发现了这个:

div p -> div.p

and you can set a style= to you HTML element, like:您可以为 HTML 元素设置一个style= ,例如:

<div style=width:100px;height:100px;background-color:red;></div>

If you wanted to ask something else, and my question doesn't help me, then please write me a commentar.如果您想问其他问题,而我的问题对我没有帮助,请给我写评论。

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

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