I have a div with an SVG inside of it
The div is outlines by the blue dots and the SVG by the green. My SVG code inside of my HTML file:
<svg class="svg" height="500px" width="50%">
<g class="chart" transform="translate(0,0)">
<g class="state-g"> (Map here) </g>
</g>
</svg>
My relevant CSS:
body, html {
height: 100%;
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
.container {
position: relative;
align-content: center;
padding-left: 10%;
padding-right: 10%;
}
.svg {
outline: 5px dotted blue;
font: inherit;
display: block;
margin: auto;
}
svg g.chart {
outline: 5px dotted green;
If you want your SVG to automatically scale to fill its container then it needs to have a viewBox attribute.
<svg class="svg" viewBox="...something...">
<g class="chart" transform="translate(0,0)">
<g class="state-g"> (Map here) </g>
</g>
</svg>
The correct values for that viewBox will depend on the bounds of the content of that SVG. Check your original map file:
viewBox, then use that.viewBox, but it had hardwired width and height, then use those. For instance, if it had width="200px" height="350px", then replace those values with viewBox="0 0 200 350".