Is there a way to style a <use>
element based on its parent class that will work consistently across different browsers?
CSS Code Example
.column-1 {
.cls-1 {
fill: red;
}
.cls-2 {
fill: green;
}
}
.column-2 {
.cls-1 {
fill: blue;
}
.cls-2 {
fill: yellow;
}
}
HTML Structure
This demo includes an SVG element with two paths that each have a specific class name.
<div class="column-1">
<svg><use xlink:href="#icon-usp_return"></use></svg>
</div>
<div class="column-2">
<svg><use xlink:href="#icon-usp_return"></use></svg>
</div>