Is there a way to adjust the size of the outermost svg
while keeping the size of the elements inside the svg
unchanged?
I've searched online but couldn't find a solution to this specific issue.
To provide context and avoid the x-y problem
, let me explain my scenario.
I have a
div
withoverflow-y: scroll
property. This allows me to scroll within thediv
when the outermostsvg
(a direct child of thediv
) exceeds thediv
dimensions.Initially, the
svg
has width and height attributes set to100%
.When necessary, I scale the
svg
vertically (increasing the viewport) and when it exceeds thediv
dimensions, a scrollbar appears.The challenge is that the content inside the
svg
scales along with thesvg
, which I want to avoid.
I considered using a viewBox
and updating it as the svg
scales, but since I didn't have a viewBox
to begin with, that approach wasn't feasible.
My attempt to use a viewBox
to address the issue was unsuccessful, as it affected other svg
elements as well.
Here is my original svg
without the viewBox
attribute:
https://i.sstatic.net/1EN1L.png
And here is the same svg
with the viewBox
attribute:
https://i.sstatic.net/OjNd8.png
The top svg
shown above is not related to the bottom svg
in any way, yet it was affected by the change in the viewBox
of the lower svg
: