Is there a way to reverse or eliminate the effect of fill: currentColor
?
.svg-icon * {
/* Targeting all sub-elements to customize icons with a specific color */
fill: currentColor;
}
.svg-icon.iconLogoGlyph * {
/* How do I cancel out fill: currentColor further down the cascade? */
fill: inherit;
/* I want to display the original 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>
I possess a series of icons created with SVG. Some of these icons include in-line styles with color indications. The common use case is to disregard these in-line fills and have them adopt the parent's color
by specifying fill: currentColor
in CSS. However, in certain instances, such as our logo, we'd prefer these inner colors to be visible. In other cases, like a footer, we'd like to replace the colors with a single chosen color.
Due to various reasons™, I am restrained to these classes present in the library. Each icon carries the class svg-icon
and a more specific class, such as iconLogoGlyph
in this scenario.
How can I nullify fill: currentColor
solely using CSS, given that I am unable to modify the classes? I've tried using :not
to target all classes except .iconLogoGlyph
, but this approach does not allow me to utilize fill: currentColor
when necessary.
What is the antithesis of fill: currentColor
? It's neither fill: inherit
nor fill: none
. I require something along the lines of
fill: just take what's inside the SVG
🤔