【发布时间】:2015-01-28 13:51:24
【问题描述】:
我想要一个 SVG 图像,其宽度与父 div 相同,高度应为其宽度的 14%。
此代码在 Firefox 中有效,但在 Chrome 中无效:
<svg
xml:space="preserve"
preserveAspectRatio="xMinYMin meet"
height="100%" width="100%"
viewBox="-1 -10 242 33">
...
</svg>
在 Chrome 中,纵横比为 1,因此 svg 内容位于正方形的顶部,其下方有很多空白。
我需要将 svg 文件内联,所以我不能使用 img 标记。
【问题讨论】:
-
This has been answered already. 只需从
<svg>标记中删除height="100%" width="100%"。 -
这使得 svg 完全消失。
-
那你可能还没有给父容器分配宽度。
-
父级是
col-md-12bootstrap calss,宽度为 100%。