"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Why Aren't My SVG Symbols Scaling Correctly in Internet Explorer?

Why Aren't My SVG Symbols Scaling Correctly in Internet Explorer?

Published on 2025-01-26
Browse:705

Why Aren't My SVG Symbols Scaling Correctly in Internet Explorer?

SVG symbols not scaling properly in IE: Additional space

Internet Explorer has a longstanding bug where it improperly scales SVGs without both width and height attributes.

Solution

A solution exists using a trick involving a element, which IE properly scales. Placing a with the same aspect ratio as the SVG within the containing

ensures the correct SVG size.

CSS

canvas {
  display: block;
  width: 100%;
  visibility: hidden;
}

svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3