使用 JavaScript,我可以更改 SVG <g> 的 Z 索引/层吗?元素? [英] With JavaScript, can I change the Z index/layer of an SVG &lt;g&gt; element?

查看:25
本文介绍了使用 JavaScript,我可以更改 SVG <g> 的 Z 索引/层吗?元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有几个复合形状().我希望能够点击并拖动它们,但我希望我现在正在拖动的那个在 Z 顺序中位于另一个的顶部,这样如果我将它拖过另一个,另一个一个应该黯然失色.

Let's say I have a couple composite shapes (<g>). I want to be able to click and drag them, but I want the one I happen to be dragging at the moment to be on TOP of the other one in the Z order, so that if I drag it over the OTHER one, the other one should be eclipsed.

推荐答案

SVG 中的 Z 索引由元素在文档中出现的顺序定义.如果要将特定形状带到顶部,则必须更改元素顺序.

Z index in SVG is defined by the order the elements appear in the document. You will have to change the element order if you want to bring a specific shape to the top.

这篇关于使用 JavaScript,我可以更改 SVG <g> 的 Z 索引/层吗?元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆