【问题标题】:How to to display a specific element (SVG portion) in SVG ViewBox如何在 SVG ViewBox 中显示特定元素(SVG 部分)
【发布时间】:2021-03-31 22:32:29
【问题描述】:

我正在将 SVG 图像显示到 Android WebView 中。我想缩放到 SVG 地图/图片的特定日食元素(SVG 部分)并使其居中显示。是否有任何 javascript 或 css 方法可以移动到 SVG 显示的特定元素(日食)。

ScrollIntoView 也不工作。

我试图找到很多,但没有任何东西对我有用。我正在绝望地寻找解决方案。

【问题讨论】:

  • 可以将svg的view box设置为ellipse的voiding box。这将只显示椭圆居中和缩放

标签: android dictionary svg webview svg.js


【解决方案1】:

获取椭圆的边界框并将视图框设置为该框:

const canvas = SVG().addTo('body').size(100, 100)
cconst ellipse = canvas.ellipse(10, 20)

canvas.viewbox(ellipse.bbox())

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-01
    • 2017-08-14
    • 1970-01-01
    • 2017-02-28
    • 2023-04-07
    • 2021-04-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多