admin管理员组文章数量:1192814
I have code like this:
<span>
<svg height="32" version="1.1" width="32" xmlns="" style="overflow: hidden; position: relative; left: -0.0166626px; top: -0.983337px;">
<desc></desc>
<defs/>
<path style="" fill="#333333" stroke="none" d="M15.985,5.972C8.422,5.972,2.289999999999999,10.049,2.289999999999999,15.078C2.289999999999999,17.955,4.302999999999999...............1,27.68,22.274Z"/>
</svg>
</span>
I cut out most of the content and replaced it with ...
This presently creates a 32 by 32 icon. What I would like to know is can I use this code to create a 100 by 100 icon? I tried changing the width and height but it made no difference.
I have code like this:
<span>
<svg height="32" version="1.1" width="32" xmlns="http://www.w3.org/2000/svg" style="overflow: hidden; position: relative; left: -0.0166626px; top: -0.983337px;">
<desc></desc>
<defs/>
<path style="" fill="#333333" stroke="none" d="M15.985,5.972C8.422,5.972,2.289999999999999,10.049,2.289999999999999,15.078C2.289999999999999,17.955,4.302999999999999...............1,27.68,22.274Z"/>
</svg>
</span>
I cut out most of the content and replaced it with ...
This presently creates a 32 by 32 icon. What I would like to know is can I use this code to create a 100 by 100 icon? I tried changing the width and height but it made no difference.
Share Improve this question asked Mar 1, 2012 at 18:16 Samantha J T StarSamantha J T Star 32.8k89 gold badges256 silver badges441 bronze badges3 Answers
Reset to default 19The width
and height
attributes on the SVG element only define the size of the drawing area. They don't scale the contents to fit that area. For that, you need to also use the viewBox
attribute, like so:
<svg viewBox="0 0 32 32" height="100" width="100" ...>
The viewBox attribute establishes the coordinate system that is used for all the child elements of the SVG. You can then use the width and height to stretch this coordinate system to the desired size.
You can use the preserveAspectRatio
attribute to decide how to scale if the aspect ratios don't match.
just throw a transform="scale(2)" and it will do the trick, ( React )
<svg
width={56}
height={56}
transform="scale(2)"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<circle cx={28} cy={28} r={24} fill="#F88423" />
<path
fillRule="evenodd"
clipRule="evenodd"
d="..."fill="#131903"
/>
</svg>
It worked for me by modifying the svg style
let svgDom = document.getElementsByTagName("svg")[0];
let newWidth=100,newHeight=90;
svgDom.style.width = newWidth+'px';
svgDom.style.height = newHeight+'px';
本文标签: javascriptHow can I resize an SVGStack Overflow
版权声明:本文标题:javascript - How can I resize an SVG? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738450764a2087473.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论