有没有办法否定或删除fill:currentColor
?
.svg-icon * {
/* Targets all sub-elements so we can deliver icons with a color override of our choice */
fill: currentColor;
}
.svg-icon.iconLogoGlyph * {
/* How do I negate fill: currentColor further down the cascade? */
fill: inherit;
/* I want the natural colors from the SVG */
}
<svg role="icon" class="svg-icon iconLogoGlyph" width="25" height="30" viewBox="0 0 25 30"><g fill="none"><path fill="#BCBBBB" d="M21 27v-8h3v11H0V19h3v8z"></path><path fill="#F48024" d="M5.402 19.101l13.561 1.96.164-2.38-13.256-2.547-.469 2.967zM7.2 12.3l12 5.6 1.1-2.4-12-5.6-1.1 2.4zm3.4-5.9l10.2 8.5 1.7-2-10.2-8.5-1.7 2zM17.1.2L15 1.8l7.9 10.6 2.1-1.6L17.1.2zM5 25h14v-3H5v3z"></path></g></svg>
由于某些原因,我被限制只能使用库中提供的类。每个图标都有一个类“svg-icon”和一个更具体的类,例如“iconLogoGlyph”。
如果我不能触碰这些类,如何仅使用CSS来否定“fill: currentColor”?我尝试使用“:not”选择除“.iconLogoGlyph”之外的所有内容,但这样做将不允许我在实际需要时使用“fill: currentColor”。
“fill: currentColor”的相反是什么?它不是“fill: inherit”或“fill: none”。我需要像“fill:just grab what's in the SVG, yo”这样的东西。
.svg-icon:not(.iconLogoGlyph) *
不起作用吗? - ccprog.svg-icon:not(.iconLogoGlyph) *
忽略currentColor
,但我希望默认状态是currentColor
,覆盖状态是使用自然颜色
。嗯。 - Aaron Shekey.svg-icon:not(.iconLogoGlyph) * { fill: currentColor; }
,完结撒花。 - ccprog