保持内部SVG的纵横比

问题描述 投票:0回答:1
html css svg aspect-ratio
1个回答
0
投票

您可以使用CSS属性aspect-ratio

p {
  color: navy;
}

.inline {
  fill: currentColor;
  display: inline-block;
  height: 1em;
  aspect-ratio: 828/1000;
}
<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0" style="position: absolute;">
    <defs>
        <symbol id="image1" viewBox="-10 0 828 1000">
            <path fill="currentColor" d="M -10 50 L 818 0 L 690 1000 L 40 700 Z" />
        </symbol>
    </defs>
</svg>
<p>Here is your inline <svg class="inline"><use href="#image1" /></svg> SVG.</p>

© www.soinside.com 2019 - 2024. All rights reserved.