问题
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