html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
svg {
border: 1px solid black;
width: 64vw;
height: 64vh;
}
svg.quadrado {
border: 1px solid black;
width: 100px;
height: 100px;
}
SVG com o aspect-ratio preservado<br><br>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" id="Capa_1" viewBox="0 0 512 512" width="512px" height="512px">
<g>
<circle style="fill:#0053AB" cx="256" cy="256" r="256" data-original="#0053AB" class="" data-old_color="#44C4FC"/>
<path style="fill:#0B3660" d="M512,256c0-10.491-0.646-20.83-1.872-30.99l-99.507-99.507L78,361l149.401,149.401 C236.792,511.445,246.331,512,256,512C397.385,512,512,397.385,512,256z" data-original="#0B3660" class="" data-old_color="#29ACE5"/>
<rect x="101.38" y="125.5" style="fill:#37474F;" width="309.24" height="215.99" data-original="#37474F" class=""/>
<rect x="255.95" y="125.5" style="fill:#263238;" width="154.67" height="215.99" data-original="#263238" class=""/>
<rect x="119.3" y="141.78" style="fill:#FEA626;" width="273.4" height="183.45" data-original="#FEA626" class=""/>
<rect x="255.95" y="141.78" style="fill:#F47C00;" width="136.75" height="183.45" data-original="#F47C00" class=""/>
<path style="fill:#1E499E" d="M285.026,166.246v65.458h-58.052v-65.458c-19.361,10.373-32.534,30.792-32.534,54.294 c0,23.533,13.21,43.975,32.615,54.334v50.349h57.893v-50.348c19.404-10.36,32.614-30.801,32.614-54.335 C317.561,197.039,304.387,176.619,285.026,166.246z" data-original="#1E499E" class=""/>
<path style="fill:#0E387C" d="M317.561,220.54c0-23.501-13.174-43.921-32.535-54.294v65.458h-29.074v93.519h28.994v-50.348 C304.351,264.515,317.561,244.074,317.561,220.54z" data-original="#0E387C" class=""/>
<rect x="78" y="319.67" style="fill:#455A64" width="356" height="41.33" data-original="#455A64" class=""/>
<rect x="255.95" y="319.67" style="fill:#37474F;" width="178.05" height="41.33" data-original="#37474F" class=""/>
</g>
</svg>
<br><br>
SVG sem o aspect-ratio preservado<br><br>
<svg preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" viewBox="0 0 512 512" >
<g>
<circle style="fill:#0053AB" cx="256" cy="256" r="256" data-original="#0053AB" class="" data-old_color="#44C4FC"/>
<path style="fill:#0B3660" d="M512,256c0-10.491-0.646-20.83-1.872-30.99l-99.507-99.507L78,361l149.401,149.401 C236.792,511.445,246.331,512,256,512C397.385,512,512,397.385,512,256z" data-original="#0B3660" class="" data-old_color="#29ACE5"/>
<rect x="101.38" y="125.5" style="fill:#37474F;" width="309.24" height="215.99" data-original="#37474F" class=""/>
<rect x="255.95" y="125.5" style="fill:#263238;" width="154.67" height="215.99" data-original="#263238" class=""/>
<rect x="119.3" y="141.78" style="fill:#FEA626;" width="273.4" height="183.45" data-original="#FEA626" class=""/>
<rect x="255.95" y="141.78" style="fill:#F47C00;" width="136.75" height="183.45" data-original="#F47C00" class=""/>
<path style="fill:#1E499E" d="M285.026,166.246v65.458h-58.052v-65.458c-19.361,10.373-32.534,30.792-32.534,54.294 c0,23.533,13.21,43.975,32.615,54.334v50.349h57.893v-50.348c19.404-10.36,32.614-30.801,32.614-54.335 C317.561,197.039,304.387,176.619,285.026,166.246z" data-original="#1E499E" class=""/>
<path style="fill:#0E387C" d="M317.561,220.54c0-23.501-13.174-43.921-32.535-54.294v65.458h-29.074v93.519h28.994v-50.348 C304.351,264.515,317.561,244.074,317.561,220.54z" data-original="#0E387C" class=""/>
<rect x="78" y="319.67" style="fill:#455A64" width="356" height="41.33" data-original="#455A64" class=""/>
<rect x="255.95" y="319.67" style="fill:#37474F;" width="178.05" height="41.33" data-original="#37474F" class=""/>
</g>
</svg>
<br><br>
SVG sem o aspect-ratio preservado, mas corrigido usando altura e largura iguais<br><br>
<svg class="quadrado" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg" version="1.1" id="Capa_1" viewBox="0 0 512 512" width="512px" height="512px">
<g>
<circle style="fill:#0053AB" cx="256" cy="256" r="256" data-original="#0053AB" class="" data-old_color="#44C4FC"/>
<path style="fill:#0B3660" d="M512,256c0-10.491-0.646-20.83-1.872-30.99l-99.507-99.507L78,361l149.401,149.401 C236.792,511.445,246.331,512,256,512C397.385,512,512,397.385,512,256z" data-original="#0B3660" class="" data-old_color="#29ACE5"/>
<rect x="101.38" y="125.5" style="fill:#37474F;" width="309.24" height="215.99" data-original="#37474F" class=""/>
<rect x="255.95" y="125.5" style="fill:#263238;" width="154.67" height="215.99" data-original="#263238" class=""/>
<rect x="119.3" y="141.78" style="fill:#FEA626;" width="273.4" height="183.45" data-original="#FEA626" class=""/>
<rect x="255.95" y="141.78" style="fill:#F47C00;" width="136.75" height="183.45" data-original="#F47C00" class=""/>
<path style="fill:#1E499E" d="M285.026,166.246v65.458h-58.052v-65.458c-19.361,10.373-32.534,30.792-32.534,54.294 c0,23.533,13.21,43.975,32.615,54.334v50.349h57.893v-50.348c19.404-10.36,32.614-30.801,32.614-54.335 C317.561,197.039,304.387,176.619,285.026,166.246z" data-original="#1E499E" class=""/>
<path style="fill:#0E387C" d="M317.561,220.54c0-23.501-13.174-43.921-32.535-54.294v65.458h-29.074v93.519h28.994v-50.348 C304.351,264.515,317.561,244.074,317.561,220.54z" data-original="#0E387C" class=""/>
<rect x="78" y="319.67" style="fill:#455A64" width="356" height="41.33" data-original="#455A64" class=""/>
<rect x="255.95" y="319.67" style="fill:#37474F;" width="178.05" height="41.33" data-original="#37474F" class=""/>
</g>
</svg>
The server is returning the SVG with the correct MIME type?
– fernandosavio
I recommend also putting your HTML code here to check another possible problem.
– Bruno Soares
I don’t know what it is MIME type, nor how to verify it. I will give a search. Thank you!
– Paulo Dos Santos
Have you checked to see if there’s any CSS interfering with the image, or the container the image is in? If you can access the URL is pq it is there... probably has a display:None, opacity:0, position:Absolute or something like that taking the image from the Stage. Even if she’s with the
fill
white #fff might be that you’re not noticing her on the screen... Check the classes etc, sometimes resolve– hugocsl
That’s the MIME type
type="image/svg+xml"
and apparently right, although using image.svg in the image tag does not need to declare MIME type, so it should be working, I believe your problem is something related to what I said above...– hugocsl
So it’s like in the example I posted. I don’t have any css.
– Paulo Dos Santos
You really need to use svg inside the tag
<object>
or you put just wanted?– hugocsl
I’m looking for a server to upload the image I have. Because this example seems to be working the way I’d like it to work with the original image I have. It’s all so confusing. I’ll run some more tests
localhost
. The page being PHP interferes with something?– Paulo Dos Santos
Be. PHP does not change anything. You can put the code that is inside the . svg right in Codepen or Jsfidelle, then we take the code and save it locally as . svg, I think it’s easier than going up . svg pro host
– hugocsl
Ah, I get it now. There’s code inside the SVG. I hadn’t yet messed with this extension. So the problem could be inside the SVG? I’ll try to post the image source code.
– Paulo Dos Santos
This is the SVG code http://jsfiddle.net/d0wohutf/
– Paulo Dos Santos