【发布时间】:2012-03-01 18:27:32
【问题描述】:
在这段 SVG 中(在 FF 8、Safari 5.1.2、Chrome 16 中都在 Mac 上尝试过),当将鼠标移到栏上时,没有一个浏览器能正确检测到每个 on-mouse-over/out 事件,有时它工作有时它不。但它在所有浏览器中都是一致的,所以它可能与 SVG 代码有关。使用 onmouseover 和 onmouseout 会得到相同的结果 - 无法正常工作。
对于 SVG rectangles 实现悬停的正确方法是什么?
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="800" height="600" version="1.1" style="display:inline">
<style type="text/css">
.bar {
fill: none;
}
.bar:hover {
fill: red;
}
</style>
<g>
<rect class="bar" x="220" y="80" width="20" height="180" stroke="black" stroke-width="1" />
</g>
</svg>
【问题讨论】: