Fit< svg>到< object>的大小。容器 [英] Fit <svg> to the size of <object> container

查看:87
本文介绍了Fit< svg>到< object>的大小。容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个标记:

#widget1 {
    height:100px;
    width:200px;
}

<div class="widget" id="widget1">
    <object data="foo.svg" type="image/svg+xml" />
</div>

我设法使< object> 元素填满外部< div> ,但内部foo.svg文件有自己的想法多大。我需要foo.svg(当然包括< svg> 元素)与< object> code>和< div>

I managed to make the <object> element fill up the outer <div>, but the inner foo.svg file has its own ideas how big it is. I need foo.svg (which consists of an <svg> element, of course) to be the same size as <object> and <div>.

推荐答案

这在svg primer

tl; dr摘要:


  • 删除svg根上的'width'和'height'属性,并添加值为0 0 wh的'viewBox'属性,其中w和h是绝对通常在width和height属性中找到的值(请注意,viewBox属性中不允许使用百分比和其他单位)

这篇关于Fit&lt; svg&gt;到&lt; object&gt;的大小。容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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