个性化阅读
专注于IT技术分析

SVG事件监听器用法示例

点击下载

在SVG中, 你可以将各种事件侦听器直接添加到SVG形状中。

例:

<!DOCTYPE html>
<html>
<body>
<svg width="500" height="150">

<rect x="10" y="10" width="100" height="75"
   style="stroke: black; fill: silver; fill-opacity: .4;"
   onmouseover="this.style.stroke = 'blue'; this.style['stroke-width'] = 5;"
   onmouseout="this.style.stroke = 'green'; this.style['stroke-width'] = 1;"/>

</svg>
</body>
</html>

立即测试

转换坐标系

使用transform属性, 可以将图形移动到新位置。你还可以旋转或缩放图形。你必须将transform属性添加到适当的SVG元素中才能转换坐标系。

赞(0)
未经允许不得转载:srcmini » SVG事件监听器用法示例

评论 抢沙发

评论前必须登录!