我有一个交互式SVG - 显示在全屏大小。 我想添加一些按钮。 是否可以在<svg>
标签内添加普通的<button>
元素?
我认为不行,但我想知道是否有类似于SVG的东西。
从一些绘图中,我得到了这样糟糕的结果:
https://jsfiddle.net/pvxr6g8k/1/
<svg version="1.1" id="svg9723" height="768" width="1268">
<g style="fill:#e6e6e6" id="g3332-7" transform="matrix(0.27404175,0,0,-0.447665,86.580009,508.16151)">
<g style="fill:#e6e6e6" clip-path="url(#clipPath3336-0-0)" id="g3334-7">
<g style="fill:#e6e6e6" transform="translate(992.5469,164.3086)" id="g3340-6">
<path inkscape:connector-curvature="0" id="path3342-2" style="fill:#e6e6e6;stroke:#241a5d;stroke-width:4.48957968;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1" d="m 0,0 c -6.937,0 -12.58,5.645 -12.58,12.58 l 0,63.277 c 0,6.937 5.643,12.581 12.58,12.581 l 279.488,0 c 6.936,0 12.58,-5.644 12.58,-12.581 l 0,-63.277 C 292.068,5.645 286.424,0 279.488,0 L 0,0 Z"></path>
</g>
</g>
</g>
<text transform="scale(0.9324557,1.072437)" id="text3390-1" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:11.87269115px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, Bold';writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none" x="413.18262" y="390.15326">
<tspan style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:'Arial Bold'" y="390.15326" x="413.18262" id="tspan3392-0" sodipodi:role="line">BUTTON</tspan>
</text>
</svg>
问题不在于视觉外观,而是结构本身不允许我使用JS绑定事件或与之交互。更不用说按钮"按下"时的视觉点击效果更难以实现。
那么,在交互式SVG中有什么解决方案?是否有类似HTML中按钮的好元素可用?
我不需要嵌入HTML按钮,任何良好的替代按钮都可以。