Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Older browsers don't calculate intrinsic dimensions from the viewBox attribute #19

Open
shawnbot opened this issue Oct 30, 2015 · 0 comments

Comments

@shawnbot
Copy link

The viewBox attribute makes can be used instead of explicit width and height to define an SVG element's aspect ratio so that they act just like images do when styled with CSS (height is scaled proportionally when you only declare width, etc.). According to the spec regarding "Intrinsic sizing properties of the viewport of SVG content" (emphasis mine):

If either/both of the ‘width’ and ‘height’ of the outermost svg element are in percentage units (or omitted) (used value is auto), the aspect ratio is calculated from the width and height values of the ‘viewBox’ specified for the current SVG document fragment. If the ‘viewBox’ is not correctly specified, the intrinsic aspect ratio cannot be calculated and is considered unspecified.

Unfortunately, most of the major browsers haven't followed this part of the spec until relatively recently. Chrome 36 introduced support for intrinsic sizing by viewBox in July, 2014; Safari didn't do it until recently, but I haven't been able to hunt down the changelog to see when; Firefox was a late adopter too, but I don't know exactly when they fixed it. iOS and Android browser support should probably be listed separately, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant