Home >Web Front-end >CSS Tutorial >Why Aren't My SVG Symbols Scaling Correctly in Internet Explorer?

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

Patricia Arquette
Patricia ArquetteOriginal
2024-12-15 15:49:17687browse

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 <div> ensures the correct SVG size.

<div>

CSS

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

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

The above is the detailed content of Why Aren't My SVG Symbols Scaling Correctly in Internet Explorer?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn