如何缩放嵌入 <object> 的顽固 SVG?标签? [英] How do I scale a stubborn SVG embedded with the <object> tag?
问题描述
我有一些指定 width
和 height
以及 viewbox
的 SVG 文件,如下所示:
I have some SVG files that specifies width
and height
as well as viewbox
like this:
<svg width="576pt" height="432pt" viewBox="0 0 576 432" > ...
但是如何以我决定的大小在浏览器中显示它们?我希望它们更小,并已尝试过:
but how to display them in the browser at a size I decide? I want them smaller and have tried:
<object width="400" data="image.svg"></object>
但后来我得到了可见的滚动条.
but then I get visible scrollbars.
如果我更改 SVG 文件以将 width
和 height
设置为 100%
,它会起作用,但我想决定无论 SVG 文件中使用什么尺寸,HTML 都是如此.这可能吗 ?
It works if I change the SVG files to set width
and height
to 100%
instead, but I want to decide the size in the HTML regardless of what sizes are used in the SVG file. Is this possible ?
推荐答案
当我在 2009 年问这个问题时,这里给出的答案都没有对我有用.因为我现在再次遇到同样的问题,我注意到使用 标签和宽度与 svg 一起工作正常.
None of the answers given here worked for me when I asked this back in 2009. As I now had the same issue again I noticed that using the <img>
tag and width together with an svg works fine.
<img width="400" src="image.svg">
这篇关于如何缩放嵌入 <object> 的顽固 SVG?标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!