何时不透明0 *不*透明?

时间:2011-06-08 13:38:35

标签: javascript svg

我有一个奇怪的问题(和一个修复),我绘制一个零不透明矩形(对于鼠标事件),但它不透明。它在过去一直是透明的,但我在代码中改变了一些东西,它不再透明。这是矩形:

shape = svgDocument.createElementNS(svgns, "rect");
shape.setAttributeNS(null, "x",      x);
shape.setAttributeNS(null, "y",      y);
shape.setAttributeNS(null, "width",  w);
shape.setAttributeNS(null, "height", h);
shape.setAttributeNS(null, "stroke", "none");
shape.setAttributeNS(null, "stroke_width", 0);
shape.setAttributeNS(null, "fill_opacity", 0);
shape.setAttributeNS(null, "stroke_opacity", 0);
shape.setAttributeNS(null, "stroke_dasharray", 0);
shape.setAttributeNS(null, "fill", "#ffffff");
shape.setAttributeNS(null, "onmouseover", "popup_on(evt)");
shape.setAttributeNS(null, "onmouseout",  "popup_off(evt)");
svgDocument.documentElement.appendChild(shape);

我改变了一些东西 - 我不确定是什么 - 并且盒子不再透明 - 它完全遮盖了背景网格线。我用Google搜索,并尝试更改填充颜色,没有任何变化。最后,我发现Mozilla MDN示例使用了“透明”填充。这适用于Chrome和FF(未尝试IE9)。

“透明”未记录为SVG 1.1 2nd edn规范中的值。有什么想法在这里发生了什么?上面的矩形有什么不寻常之处吗?

1 个答案:

答案 0 :(得分:2)

这些SVG属性是否应该包含破折号而不是下划线(即fill-opacity)?