请参考下面的正确代码.
Please refer below rect code.
<rect id="container_svg_ChartArea" x="146.8" y="20" width="633.2" height="414" fill="White" stroke-width="1" stroke="Gray"></rect>我尝试获取矩形边界框值,它不返回任何内容,即x = 0,y = 0,width = 0,height = 0时为"0"
i tried get the rectangle bounding box value it returns nothing i.e."0" for x=0,y=0,width=0,height=0
$("#container_svg_ChartArea")[0].getBBox()但是当我获得x/y/width/height的属性时,它会返回一些值
but when i get the attribute for x/y/width/height it returns some value
$("#container_svg_ChartArea").attr("x") ->value returned.与路径元素和矩形元素相同.
same for path element as well as rectangle element.
出了什么问题?
此处没有解决方案.
如何获取jQuery中svg路径的边界框或矩形(getBBox())
这就是为什么我创建了另一个线程.它不是重复的线程.
thats why i created another thread. it is not duplicate thread.
谢谢
Siva
推荐答案看此示例,了解如何获取和管理svg元素的边框
Look this example on how to get and manage the bounding box of svg elements
www.janvas/illustrators_designers_developers/projects/janvas2D_web/examples_EN.php?exampleName = ufo_animation_EN
一般
var svgElement = document.getElementById('the id of your element'); bbox = svgElement.getBBox(); console.log( bbox.x ) ; console.log( bbox.y ) ; console.log( bbox.width ) ; console.log( bbox.height ) ;更多推荐
getBBox()对于rect或path不返回任何内容
发布评论