I have this SVG path that changes its color on hover
. However, I want its drop-shadow which I created using a filter
element to disappear on hover
too. Is there a way to do this in CSS? I tried using fill-opacity
-- it worked on the rect
element, but not on the filter
element.
Here's the fiddle with the shadow still visible: http://jsfiddle.net/4d6j4/
I was able to remove the shadow by removing the filter altogether in CSS:
See working jsFiddle demo
Then, after some finagling, I was able to successfully transition the drop shadow and the fill color. I had to put the shadow on
svg
instead of thesvg rect
with separate:hover
styles as well:See working jsFiddle demo
HTML
CSS
One caveat seems to be that you have to use
transition: all
vstransition: filter
.Also, the CSS filter property is not fully cross-browser compatible either.
Here's the current Browser Compatiblity as of 2014.07.21:
You can animate flood-opacity property of feFlood element by css.
http://jsfiddle.net/defghi1977/SwHDR/
svg structure:
css:
for chrome: Chrome fails to find feFlood element by selector at inline svg. So we need to rewrite css selector by :nth-child pseudo class like this.
http://jsfiddle.net/defghi1977/djMq8/1/