2011-06-08 126 views
0

我有一个好奇的问题(和修复),我绘制了一个不透明的矩形(用于鼠标事件),但它不透明。它在过去一直是透明的,但我已经在代码中改变了一些东西,并且它不再透明。这是矩形:何时不透明0 *不透明?

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)。

“transparent”在SVG 1.1 2nd edn规范中没有记录为值。任何想法发生了什么?上面的矩形有什么不寻常的地方吗?

+1

查看您的版本控制修订历史记录,并找出您更改的内容。 – 2011-06-08 13:47:52

+0

没有历史。只写了一小时前的代码.. :) – EML 2011-06-08 14:02:47

+1

经验教训,我希望! – 2011-06-08 14:18:20

回答

2

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

+0

谢谢!固定。好奇Chrome没有说什么。 – EML 2011-06-08 14:51:18