Here is a code demo
I have a SVG with an unknown height. I can figure it out after I load in json and use javascript+math but is there any css I can use to dynamically s
An alternative is to do similar to the above JS but set viewBox
(note, not viewbox
!) instead of width
and height
from JS with values from the getBBox()
call. Then use preserveAspectRatio="xMidYMid meet"
or similar.
var svg = document.getElementById("x1");
svg.setAttribute("viewBox", "0 0 32 18.4");
https://jsfiddle.net/t88pLgbb/4/