I've been playing around with SVG
s in websites, and I've been trying to get filter
s to work, but I can't seem to get it right.
The problem is that the svg
disappears completely once I apply a defined filter
. I've tried to apply the filter
inline, just to see if it worked, like this:
<symbol id="circle" viewBox="0 0 400 209.603" filter="url('#blur-filter')">
...
</symbol>
but with no success.
Ultimately, my goal is that I would be able to apply the filter
s via CSS, but I can't seem to get it to work, and this is the first time I've really played around with SVG
s, so I don't know if I'm making some obvious mistake.
Code:
.svg-circle:hover {
filter: url("#blur-filter");
}
.svg-grey {
fill: #333;
}
<svg xmlns="http://www.w3.org/2000/svg" style="display:none">
<defs>
<filter id="blur-filter">
<feGaussianBlur in="SourceGraphic" stdDeviation="2" />
</filter>
<symbol id="circle" viewBox="0 0 400 209.603">
<circle cx="100" cy="100" r="100" />
</symbol>
</defs>
</svg>
<svg>
<use xlink:href="#circle" class="svg-circle svg-grey"/>
</svg>
I want the filter
to be applied when I hover over the element. My other question is how I can incorporate this with CSS transitions
, so that the blur
gets applied gradually, like other css3 transitions
.
I also want the filters to be global, so they can be reused across multiple svg
images whenever I want, so define once, and reuse.
I've also created a Codepen to demonstrate my problem.