【问题标题】:SVG CSS3 animation is not showing on SafariSVG CSS3 动画未在 Safari 上显示
【发布时间】:2018-10-17 09:49:57
【问题描述】:

以下 SVG 代码可在 Chrome 中运行,但在 Safari 中无法运行。我不知道是什么问题。你能帮帮我吗?

我已经添加了-wekbit-animation 和-webkit-frames。据说 Safari 应该能识别这 2 个标签。

    <svg xmlns="http://www.w3.org/2000/svg" version="1.1" 
    xmlns:xlink="http://www.w3.org/1999/xlink" 
    preserveAspectRatio="none" 
    x="0px" y="0px" 
    width="2048px" height="1536px" 
    viewBox="0 0 2048 1536" xml:space="preserve">
    <defs>
      <path id="Layer_green_2_0_1_STROKES" stroke="#2C9842" 
            stroke-width="3.5" stroke-linejoin="round" 
            stroke-linecap="round" fill="#FFFFFF" 
            d="M 397.55 799.35 L 618.95 775.525 826.45 768.95 
              1027.1 693.3 1254.55 684.2" class="path"></path>
    </defs> 
    <g transform="matrix( 1, 0, 0, 1, 0,0) "> 
      <use xlink:href="#Layer_green_2_0_1_STROKES"></use>
    </g>
    <style>
      .path {
        stroke-dasharray: 1000;
        stroke-dashoffset: 1000;
        animation: dash 5s linear alternate infinite;
      }

      @keyframes dash {
       from {
          stroke-dashoffset: 1000;
       }
       to {
         stroke-dashoffset: 0;
       }
     }
     @-webkit-keyframes dash {
      from {
        stroke-dashoffset: 1000;
      }
      to {
        stroke-dashoffset: 0;
      }
     }

    </style>
    </svg>

【问题讨论】:

  • 这个 SVG 还有多少?这不是完整的文件。
  • 抱歉,我刚刚更新了完整的 SVG 代码
  • 另外一件事,这个 SVG 文件是从 &lt;img src="some.svg"&gt; 链接到的还是直接嵌入到 HTML 中?
  • 我只是用浏览器直接打开了这个SVG文件,但最终会嵌入到HTML中。谢谢。

标签: css svg safari css-animations


【解决方案1】:

删除&lt;defs&gt;标签,它将显示在Safari中

【讨论】:

    猜你喜欢
    • 2015-11-09
    • 2019-06-02
    • 1970-01-01
    • 1970-01-01
    • 2014-08-30
    • 2017-02-21
    • 1970-01-01
    • 2015-04-18
    • 1970-01-01
    相关资源
    最近更新 更多