我使用了focusable属性来强制SVG元素在HTML文档中获取焦点。
我需要通过TAB键在SVG标记中导航到SVG元素。如文档所述(http://www.w3.org/TR/SVGTiny12/interact.html#focusable-attr)
但是我无法做到。我已经将focusable
属性设置为true
,每个元素的tabindex
设置为0
。
以下是我的代码:
<div style="border: solid yellow 2px;" tabindex="0">
<svg tabindex="0" width="900px" height="500px" viewBox="0 0 95 50" style="border: solid red 1px;" focusable="true"
xmlns="http://www.w3.org/2000/svg">
<g data-Name="group" tabindex="0" stroke="green" fill="white" stroke-width="5" data-tabindex="0" style="border: solid green 1px;" focusable="true">
<circle tabindex="0" cx="20" cy="25" r="5" focusable="true" data-Name="shape 1" data-tabindex="0" />
<circle tabindex="0" cx="40" cy="25" r="5" focusable="true" data-Name="shape 2" data-tabindex="0" />
<circle tabindex="0" cx="60" cy="25" r="5" focusable="true" data-Name="shape 3" data-tabindex="0" />
<circle tabindex="0" cx="80" cy="25" r="5" focusable="true" data-Name="shape 4" data-tabindex="0" />
</g>
</svg>
我已经在谷歌浏览器中测试了这段代码。有没有办法达到目的?