I'm embedding SVG definitions for common icons we're using throughout our site:
<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0" display="none">
<symbol id="icon-1" viewbox="0 0 113.8 113.8">
<title>Icon 1</title>
<g>
<circle class="st2 outter-circle" cx="56.9" cy="56.8" r="55" />
<line class="st1" x1="56.9" y1="71.5" x2="56.9" y2="86.3" />
</g>
</symbol>
</svg>
(Truncated that for this example.)
Then I'm including it in my markup as:
<svg viewBox="0 0 100 100" class="campus-icon white five-eighths">
<use xlink:href="#icon-1"></use>
</svg>
The problem I'm running into is choosing a color scheme for the icon by setting a class for the SVG object.
These are the default styles:
.st1 {
fill:none;
stroke:#363636;
stroke-width:0.75;
stroke-linecap:round;
stroke-linejoin:round;
stroke-miterlimit:10;
}
.st2 {
fill:none;
stroke:#363636;
stroke-width:2;
stroke-miterlimit:10;
}
What I tried doing is allowing the class on the SVG object help define the stroke color of the icon:
.campus-icon.white .st1,
.campus-icon.white .st2 {
stroke: #FFF;
}
This seems to work in Firefox, but not in Chrome or Safari.
Because my icons have two colors, this is something I really need to figure out (if it's even possible).
From what I can tell Safari and Chrome won't allow me to use a selector on the SVG object followed by a selector within the SVG itself.
To test this theory, I took this working example (SVG CSS Hover Styling) and created a CodePen instance (http://codepen.io/ericrovtar/pen/ZeZqRE).
Anyone know if there is a way to accomplish this?
Thanks!
-Eric