I am currently developing a website where users can interact with an SVG image using textboxes. One of my goals is to make sure the SVG image scales to fit the container div.
For example, if the SVG was the same height as the container but only 10 pixels wide, doubling the height would make the width appear to be 5 pixels.
My webpage layout consists of numbers on the left side and the image on the right side. As a result, resizing the browser changes the shape of the SVG's container element, making it difficult to set fixed dimensions for the container in the SVG code.
Although I have searched online for solutions involving the use of the viewBox
attribute, I have not been able to find a way to implement it without specifying a hard-coded container size.
Feel free to check out this fiddle with my editor setup: