getBBox()对于rect或path不返回任何内容

编程入门 行业动态 更新时间:2024-10-20 16:29:24
本文介绍了getBBox()对于rect或path不返回任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

请参考下面的正确代码.

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不返回任何内容

本文发布于:2023-11-06 13:48:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563866.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内容   getBBox   rect   path

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!