svg size auto

相關問題 & 資訊整理

svg size auto

You create a fabulous header logo in Inkscape and you copy and paste the SVG code it spits out into your WordPress header file. Of course, you're not giving up on last year's resolution to always use responsive design, so you set svg.banner widt,DEMO. You need to define a viewBox on each element that you link to. because there can be different elements in one SVG document. So remove the viewBox from the element you link to. Add a viewBox to the place you're linking from. I suggest you add the, I don't think 'auto' is a valid value for the 'length' attr of a svg image element. Take a look at the spec here. You might want to use '100%'. You could load the image then inspect the width and height onload. JSFiddle: http:, If the SVG element does not have any width and height attributes, then the width/height should be calculated according to the CSS specs, as pointed out by Robert Longson. However, those values will not reflect the proper dimensions of the SVG's conte, <div style= backgroundColor: 'lightpink', resize: 'horizontal', overflow: 'hidden', width: '1000px', height: 'auto', }} > <svg width="100%" viewBox="113 128 972 600" preserveAspectRatio, I actually found the solution which is far less involved (but a bit hacky) than doing aspect ratio calculations. The trick was that I created an invisible line (no stroke) from the top left corner to the bottom right corner of the SVG canvas. Then I got , You can set width: 100% & height: auto in svg:not (:root ) selector for this. check updated snippet below. .hero-wave position: absolute; bottom: 20px; left: 0px; right: 0px; width: 100%; height: 20%; } svg:not (:root ) width:100%; height: auto; } , AFAIK you cannot do this with pure CSS. Your SVG does not specify all required attributes and thus default sizes will be used instead. You will have to specify the viewport/size at the SVG element. This should be no problem, because you have hard coded v, It appears, by adding max-width to the css for the svg, will format the sizing exactly as i need it. This works for Webkit browsers and Firefox, which fortunately meets my requirements, however if IE support was essential then this is not really a soluti

相關軟體 Inkscape 資訊

Inkscape
Inkscape 是在 Windows,Mac OS X 和 Linux 上運行的專業質量矢量圖形軟件。它被全世界的設計專業人員和愛好者用來創建各種各樣的圖形,如插圖,圖標,徽標,圖表,地圖和網頁圖形。 Inkscape 選擇版本:Inkscape 0.92.2(32 位)Inkscape 0.92.2(64 位)使用 W3C 開放標準的 SVG(Scalable Vector Graphics)... Inkscape 軟體介紹

svg size auto 相關參考資料
How to Scale SVG | CSS-Tricks

You create a fabulous header logo in Inkscape and you copy and paste the SVG code it spits out into your WordPress header file. Of course, you&#39;re not giving up on last year&#39;s resolution to al...

https://css-tricks.com

css - height: auto on SVG not working - Stack Overflow

DEMO. You need to define a viewBox on each element that you link to. because there can be different elements in one SVG document. So remove the viewBox from the element you link to. Add a viewBox to t...

https://stackoverflow.com

Auto width and height for SVG image - Stack Overflow

I don&#39;t think &#39;auto&#39; is a valid value for the &#39;length&#39; attr of a svg image element. Take a look at the spec here. You might want to use &#39;100%&#39;. You could load the image th...

https://stackoverflow.com

css - Autosize an SVG? - Stack Overflow

If the SVG element does not have any width and height attributes, then the width/height should be calculated according to the CSS specs, as pointed out by Robert Longson. However, those values will n...

https://stackoverflow.com

html - How can I make an svg scale with its parent container ...

&lt;div style= backgroundColor: &#39;lightpink&#39;, resize: &#39;horizontal&#39;, overflow: &#39;hidden&#39;, width: &#39;1000px&#39;, height: &#39;auto&#39;, }} &gt; &lt;svg width=&quot;100%&quot; ...

https://stackoverflow.com

javascript - How to get the actual size of an embedded SVG element ...

I actually found the solution which is far less involved (but a bit hacky) than doing aspect ratio calculations. The trick was that I created an invisible line (no stroke) from the top left corner to...

https://stackoverflow.com

html - How to scale inline SVG to parent containers width and ...

You can set width: 100% &amp; height: auto in svg:not (:root ) selector for this. check updated snippet below. .hero-wave position: absolute; bottom: 20px; left: 0px; right: 0px; width: 100%; height...

https://stackoverflow.com

javascript - How I can set auto height to svg element? - Stack ...

AFAIK you cannot do this with pure CSS. Your SVG does not specify all required attributes and thus default sizes will be used instead. You will have to specify the viewport/size at the SVG element. T...

https://stackoverflow.com

css - Inline svg scaling - auto width - Stack Overflow

It appears, by adding max-width to the css for the svg, will format the sizing exactly as i need it. This works for Webkit browsers and Firefox, which fortunately meets my requirements, however if IE...

https://stackoverflow.com