【问题标题】:SVG won't scale full screen in Chrome/SafariSVG 不会在 Chrome/Safari 中缩放全屏
【发布时间】:2013-12-19 22:34:02
【问题描述】:

我正在尝试将 SVG 缩放为它的父级(主体)的全宽,并且由于某种原因它不会在 chrome/safari 上让步 - 但适用于 Firefox

    <svg class="svg-graphic" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100">
      <defs>
        <pattern id='image' width="100%" height="140%" viewBox="0 0 100 100" preserveAspectRatio="none">
            <image xlink:href='http://25.media.tumblr.com/28c4327f8d41f73e2ed6ccdf7da27efb/tumblr_mw4knrtHlH1qz7p1oo1_500.jpg' width="100" height="100" preserveAspectRatio="none"></image>
       </pattern>
      </defs>
      <polygon points="0, 0, 0, 5, 25, 40, 50, 5, 75, 40, 100, 5, 100, 0,)" fill="url(#image)" />
    </svg>

CSS

html, body { 
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        margin:0; 
        padding:0; 
    }

    .svg-graphic {
        position: fixed;
        top:0;
        right: 0;
        bottom: 0;
        left: 0;            
        z-index: 10;
    }

关注这个帖子here

【问题讨论】:

    标签: css svg


    【解决方案1】:

    您是否考虑过使用 SVG 作为背景图片并将 background-size 属性设置为覆盖?

        background-image: url(yoursvg.svg);
        background-repeat: no-repeat;
        background-size: cover;
    

    【讨论】:

    • 我会将这些形状分层多次,因此需要它们是单独的 SVG
    猜你喜欢
    • 2020-07-26
    • 2014-10-30
    • 2012-07-30
    • 2013-09-19
    • 1970-01-01
    • 2019-08-18
    • 2019-10-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多