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

Scaling referenced (<use>) inlined SVGs with CSS by using height/width along with auto #769

Open
openscript opened this issue Dec 7, 2022 · 1 comment

Comments

@openscript
Copy link

According to this guide on the root svg element the width/height or the viewbox needs to be set, so the svg can properly scaled via CSS, when either height or width is set to auto.

The generated sprite from svg-sprite I embed like this:

<svg version="2.0">
  <use href="sprite.svg#logo" />
</svg>

I think it would be a great feature for svg-sprite to export a JSON file with some meta information about the sprites like width, height and viewBox, which then can dynamically added.

@Kreeg
Copy link
Member

Kreeg commented Dec 15, 2022

@openscript hello!
All the data (except viewbox) can be found here in the shape field. You can easily calculate the viewBox like 0 0 ${shape.width.inner} ${shape.height.inner}

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

2 participants