7

Look at the example:

.container {
   background-image:url("http://svgshare.com/i/3cM.svg");
   background-position:center center;
   background-repeat:no-repeat;
   width:400px;
   height:200px;
   background-color:#eef;
   border-bottom:1px solid #000;
   background-size:100% 100%;
}
<div id="container1" class="container"></div>

Related question: Stretch a background image (SVG) to 100% width and 100% height?

Blackbam
  • 14,898
  • 22
  • 85
  • 134

2 Answers2

19

Open your .svg file and set

preserveAspectRatio="none"

within the SVG tag.

Blackbam
  • 14,898
  • 22
  • 85
  • 134
holden
  • 1,635
  • 11
  • 19
0

As suggested in a comment, wrap the svg container inside another one and give the wrapper the dimensions you need. In this case, I set the wrapper to 100vw width and 100vh height. Change the wrapper dimensions and notice that the svg will follow.

html, body {
  padding:0;
  margin:0;
}

.wrapper {
  width:100vw;
  height:100vh;
}

.container {
   background-image:url("http://svgshare.com/i/3cM.svg");
   background-position:center center;
   background-repeat:no-repeat;
   width:100%;
   height:100%;
   background-color:#eef;
   border-bottom:1px solid #000;
   background-size:100% 100%;
}
<div class="wrapper">
  <div id="container1" class="container"></div>
</div>
Julio Feferman
  • 2,598
  • 3
  • 14
  • 26