Reputation: 19376
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?
Upvotes: 7
Views: 5267
Reputation: 1779
Open your .svg file and set
preserveAspectRatio="none"
within the SVG tag.
Upvotes: 22
Reputation: 2676
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>
Upvotes: 0