Is there's a way to make svg element be possible to hightlight on html page?

耗尽温柔 提交于 2021-02-05 12:13:59

问题


I have an svg element on page, which will be possible to edit, but for this I need to select it (see screenshot example with text), like usual text or image on the page. Can't do it with svg element or find any information how to achieve it.

<!DOCTYPE html>
<html>
<body>
<div style="height:100px;width:100px;">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
 </svg>
</div>

</body>
</html>

回答1:


Add a tabindex attribute to make it selectable (same as html).

<!DOCTYPE html>
<html>
<body>
<div style="height:100px;width:100px;">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
<circle tabindex="1" cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
 </svg>
</div>

</body>
</html>


来源:https://stackoverflow.com/questions/53224880/is-theres-a-way-to-make-svg-element-be-possible-to-hightlight-on-html-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!