|
|
|
|
|
by kjhughes
2398 days ago
|
|
For a constant height, why do width values between 0 and 100 cause (x axis) displacement, but width values above 100 cause scale reduction in both dimensions? (A similar phenomena can be observed for a constant width while varying the height values.) |
|
This is due to the preserveAspectRatio property on the svg element. Its default value is `meet`, which scales the svg with three rules:
- aspect ratio is preserved - the entire viewBox is visible within the viewport - the viewBox is scaled up as much as possible, while still meeting the other criteria
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/p...
If you fiddle with the attribute value in the Dev Tools, try setting it to `xMinYMid` or `none` to see if that gives you a good sense of how it works. I'm worried that it might just confuse if not explained well :)