使 css 背景图片 (svg) 响应

Make css background image (svg) responsive

我想使用 SVG 文件作为背景图像 (css)。

这是我的 SVG:

<?xml version="1.0"?>
<svg width="428" height="100" xmlns="http://www.w3.org/2000/svg">
 <!-- Created with Method Draw - http://github.com/duopixel/Method-Draw/ -->

 <g>
  <title>background</title>
  <rect fill="none" id="canvas_background" height="102" width="430" y="-1" x="-1"/>
  <g display="none" overflow="visible" y="0" x="0" height="100%" width="100%" id="canvasGrid">
   <rect fill="url(#gridpattern)" stroke-width="0" y="1" x="1" height="400" width="580"/>
  </g>
 </g>
 <g>
  <title>Layer 1</title>
  <text stroke="#000" transform="matrix(1.22606 0 0 1.22606 -24.7533 -46.6879)" opacity="0.3" font-style="italic" xml:space="preserve" text-anchor="left" font-family="Helvetica, Arial, sans-serif" font-size="24" id="svg_1" y="87.150366" x="22.228393" stroke-width="0" fill="#000000">Hello world!</text>
 </g>
</svg>

我用 http://b64.io 编码并像这样使用它:

#new-hello-world {
  background-image: url(…);
  background-repeat: no-repeat;
}

现在我的问题是 SVG 没有响应。我该如何解决这个问题?

如有任何帮助,我们将不胜感激。

编辑:

我已经尝试将 svg 宽度和高度设置为 100%,但没有成功。

<svg> 元素一个 viewBox 属性,例如viewBox = "0 0 428 100" 尽管 chipChocolate.py 对 viewBox="0 0 580 400" 的建议可能会更好,具体取决于您想要看到的内容。