简体   繁体   中英

Making svg image fluid


Im trying to make my svg image in a fluid website so i need it to rescale when the browser is smaller/bigger, but im not having much success. Any suggestions would be really apreciated
Thanks! here´s my code:

<div class="five columns" id="logo">

    <svg width="300" height="160">
        <image xlink:href="/Users/MaxRuizTagle/Desktop/guardado por illustrator/logoprobando.svg" src="" width="270" height="200"/>
    </svg>

</div>

css:

#logo {
        position: absolute;
        top:-35px;
    }

While you can set a height and width on an SVG, you really should be setting a viewbox before resizing ...

<svg width="300" height="160" viewBox="0 0 300 160">

... this will ensure that the internal scale will be aligned with your defined height and width .

Here's an awesome article: http://tutorials.jenkov.com/svg/svg-viewport-view-box.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM