I am struggling with an SVG graphic that I have created. Here is the code:
<svg width='36' height='30'>
<defs>
<linearGradient id="normal-gradient" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color:rgb(81,82,84); stop-opacity:.4"/>
<stop offset="100%" style="stop-color:rgb(81,82,84); stop-opacity:1"/>
</linearGradient>
<linearGradient id="rollover-gradient" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color:rgb(0,105,23); stop-opacity:.5"/>
<stop offset="100%" style="stop-color:rgb(0,105,23); stop-opacity:1"/>
</linearGradient>
<linearGradient id="active-gradient" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color:rgb(0,0,0); stop-opacity:.4"/>
<stop offset="100%" style="stop-color:rgb(0,0,0); stop-opacity:1"/>
</linearGradient>
</defs>
<text x="8" y="25" style="font-size: 29px;" font-family="Arial">hello world</text>
</svg>'
My issue arises when setting the fill
attribute of the text
element using CSS and trying to switch between different gradients based on hover state. While this setup works fine in Chrome and Safari, Firefox does not display the text. Upon inspecting the element, I noticed that Firefox appends a none
value at the end of my fill: url(#...)
CSS attribute. Even attempts to remove the none
keyword using Firebug result in deletion of the entire attribute. Any ideas why this is happening?
EDIT:
It's worth mentioning that removing the CSS for setting the fill
property and directly hardcoding it into the text
element (without an inline style
attribute) makes the text display correctly on all browsers.