简体   繁体   English

带有对象标签的SVG在Safari中无法缩放

[英]SVG With Object Tag Doesn't Scale In Safari

I have two svg images on my home page that are inside object tags. 我的主页上有两个svg图像,它们位于对象标记内。 They scale beautifully when the browser is resized in Chrome and Firefox, but in Safari they won't scale, they just get get off. 在Chrome和Firefox中调整浏览器的大小时,它们的缩放比例很好,但是在Safari中,它们不会缩放,只能下车。 I have tried making adjustments to the width and height of the svg image itself but that just causes the svg to become too large on tablet size screens. 我尝试过调整sv​​g图像本身的宽度和高度,但这只会导致svg在平板电脑尺寸的屏幕上变得太大。 I've searched and searched for a solution, but have yet to find one. 我已经搜索了一个解决方案,但尚未找到解决方案。 While I wish there was a way to just target Safari since it works great in both Chrome and Firefox, if anyone can offer some help with this I would greatly appreciate it. 尽管我希望有一种针对Safari的方法,因为它在Chrome和Firefox中都可以正常工作,但是如果有人可以提供一些帮助,我将不胜感激。

My html code for one of the svg images: 我的svg图像之一的html代码:

    <a href="about.html">
            <div class="svg-container">
                <object class="img-responsive" type="image/svg+xml" 
                data="images/portrait-md.svg" >
               <img src="images/portrait-md.png" />
                </object>
           </div>
        </a>

The css I have used for the div container class: 我用于div容器类的CSS:

    .svg-container {
        display: inline-block;
        overflow: hidden;
        position: relative;
        vertical-align: middle;
    }

    .svg-container object {
        pointer-events: none;
    }

    .img-responsive {
        display: block;
        height: auto;
        width: 100%;
        position: relative;
     }

My site: http://rachelhkay.com 我的网站: http : //rachelhkay.com

You can make the width and height of the svg 100% in css. 您可以在CSS中将SVG的宽度和高度设为100%。

svg {
height: 100%;
width: 100%;
}

For more information. 欲获得更多信息。 Visit this link below, and see if that helps. 请访问下面的此链接,看看是否有帮助。

http://benfrain.com/attempting-to-fix-responsive-svgs-in-desktop-safari/ http://benfrain.com/attempting-to-fix-sensitive-svgs-in-desktop-safari/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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